Root/plasma/kernel/dlltest.c

1// dlltest.c
2// Compile this program with "make dlltest".
3// Then ftp test.bin to /flash/bin/dlltest.
4// Then from a telnet prompt type "dlltest".
5#include "dll.h"
6
7
8void SocketReceive(IPSocket *socket)
9{
10}
11
12
13void MyThread(void *sock)
14{
15   char buf[80];
16   int i, bytes;
17   IPSocket *socket = sock;
18
19   for(i = 0; i < 10; ++i)
20   {
21      bytes = IPRead(socket, buf, sizeof(buf)-1);
22      buf[bytes] = 0;
23      IPPrintf(socket, "%d %s\n", i, buf);
24      OS_ThreadSleep(100);
25   }
26   socket->funcPtr = socket->userFunc; //restore socket receive function
27}
28
29
30// Function shouldn't block
31void Start(IPSocket *socket, char *argv[])
32{
33   IPPrintf(socket, "Hello from dlltest\n");
34   socket->userFunc = socket->funcPtr; //remember prev socket receive func
35   socket->funcPtr = SocketReceive; //new socket receive function
36   OS_ThreadCreate("MyThread", MyThread, socket, 100, 0);
37}
38
39

Archive Download this file

Branches:
master



interactive