4 #include <sys/socket.h>
5 #include <netinet/in.h>
7 int main (int argc, char *argv[])
9 int s, len, o, port = 6666;
11 struct sockaddr_in addr;
12 socklen_t addr_len = sizeof addr;
15 port = atoi (argv[1]);
17 s = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
21 setsockopt (3, SOL_SOCKET, SO_REUSEADDR, &o, len);
23 addr.sin_family = AF_INET;
24 addr.sin_port = htons (port);
25 addr.sin_addr.s_addr = INADDR_ANY; /* receive broadcasts */
27 bind (s, (struct sockaddr *) &addr, sizeof addr);
30 len = recvfrom (s, buf, sizeof buf, 0, (struct sockaddr *) &addr, &addr_len);
33 if (write (1, buf, len) != len)
34 fprintf(stderr, "WARNING: serial characters dropped\n");