|
|
1.1 root 1: /* test.c - main */
2:
3: #include <conf.h>
4: #include <kernel.h>
5: #include <network.h>
6:
7: /*------------------------------------------------------------------------
8: * main -- run UDP echo server and Xinu pseudo-shell
9: *------------------------------------------------------------------------
10: */
11: main()
12: {
13: int eserver();
14: Bool first;
15:
16: /* start UDP echo server */
17:
18: resume( create(eserver, 400, 30, "UDPecho", 0) );
19:
20: for (first=TRUE ; TRUE ; first=FALSE) {
21: pshell(first);
22: }
23: }
24:
25: static struct xgram buff; /* Here because the stack is small */
26:
27: /*------------------------------------------------------------------------
28: * eserver - implement UDP echo server that runs in background
29: *------------------------------------------------------------------------
30: */
31: eserver()
32: {
33: int echodev;
34: int len;
35:
36: echodev = open(NETWORK, ANYFPORT, UECHO);
37:
38: while (TRUE) {
39: len = read(echodev, &buff, sizeof(struct xgram));
40: if (len == SYSERR)
41: continue;
42: write(echodev, &buff, len);
43: }
44: }
45:
46: /*------------------------------------------------------------------------
47: * dumpit - really just to add dump routines to memory image for debug
48: *------------------------------------------------------------------------
49: */
50: dumpit()
51: {
52: /*T*/
53: prdump();
54: rfdump();
55: dgdump();
56: adump();
57: /*T*/
58: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.