blob: f1618e520ed18429decf4a9a97fc6d315a8b3a4e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "network.h"
int
main (int argc, char *argv[])
{
int cfd;
bound * rt;
int len;
unsigned char tbuf[8192];
rt = net_bind (NULL, 2000);
if (rt == NULL) {
perror ("net_bind");
exit (EXIT_FAILURE);
}
cfd = net_accept (rt->bs, NULL, 0);
if (cfd <= 0) {
perror ("net_accept");
exit (EXIT_FAILURE);
}
/* now deep down to the guts */
len = 1;
while (len > 0 && 1) {
len = read (cfd, tbuf, sizeof (tbuf));
printf ("%d\n", len);
}
close (cfd);
net_boundfree (rt);
exit (EXIT_SUCCESS);
}
|