5 #include <sys/socket.h>
11 const int tcp_port_rdp = 3389;
12 int create_server_socket();
17 int server_sock = create_server_socket();
19 tcp_recv_connect(server_sock);
24 int create_server_socket()
26 int server_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
27 const unsigned int one = 1, zero = 0;
28 struct sockaddr_in addr;
31 setsockopt(server_sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
32 ioctl(server_sock, FIONBIO, &zero);
34 addr.sin_family = AF_INET;
35 addr.sin_addr.s_addr = INADDR_ANY;
36 addr.sin_port = htons(tcp_port_rdp);
39 err = bind(server_sock, (struct sockaddr *)&addr, sizeof(struct sockaddr));
44 /* try to recover from recoverable errors... */
45 if (errno == ENOMEM || errno == EADDRINUSE) {
46 puts("Waiting 1 sec before trying again...");
55 listen(server_sock, 20);
65 /* receive ISO packets */