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 iso_recv_connect(server_sock);
20 printf("Got connection.\n");
22 printf("Client closed.\n");
26 int create_server_socket()
28 int server_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
29 const unsigned int one = 1, zero = 0;
30 struct sockaddr_in addr;
33 setsockopt(server_sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
34 ioctl(server_sock, FIONBIO, &zero);
36 addr.sin_family = AF_INET;
37 addr.sin_addr.s_addr = INADDR_ANY;
38 addr.sin_port = htons(tcp_port_rdp);
41 err = bind(server_sock, (struct sockaddr *)&addr, sizeof(struct sockaddr));
46 /* try to recover from recoverable errors... */
47 if (errno == ENOMEM || errno == EADDRINUSE) {
48 puts("Waiting 1 sec before trying again...");
57 listen(server_sock, 20);
64 if (!mcs_recv_connect_initial())
65 error("MCS_CONNECT_INITIAL recv failed");
66 mcs_send_connect_response();
72 while ((s = rdp_recv(&type)) != NULL) {
73 printf("RDP packet! type %u\n", type);