1 #include "mem_config.h"
7 # include <arpa/inet.h>
10 # include <sys/socket.h>
13 # include <netinet/in.h>
16 // $0 -u nobody -p <port>
17 int main(int argc
, char **argv
) {
18 short port
= argc
== 5 ? atoi(argv
[4]) : 11211;
19 struct sockaddr_in servaddr
;
20 memset(&servaddr
, 0, sizeof(struct sockaddr_in
));
22 servaddr
.sin_family
= AF_INET
;
23 servaddr
.sin_addr
.s_addr
= htons(INADDR_ANY
);
24 servaddr
.sin_port
= htons(port
);
26 int listen_fd
= socket(AF_INET
, SOCK_STREAM
, 0);
27 bind(listen_fd
, (struct sockaddr
*) &servaddr
, sizeof(servaddr
));
28 listen(listen_fd
, 10);
29 printf("Listening (%d) on port %d\n", listen_fd
, port
);
31 int comm_fd
= accept(listen_fd
, NULL
, NULL
);
32 printf("Connection (%d) accepted, now do nothing...\n", comm_fd
);