1 // RUN: %clangxx -O0 -g %s -o %t && %run %t
3 #include <netinet/in.h>
4 #include <sys/socket.h>
14 struct sockaddr_in server
= {}, client
= {};
19 fd
= socket(AF_INET
, SOCK_STREAM
, 0);
23 server
.sin_family
= AF_INET
;
24 server
.sin_addr
.s_addr
= INADDR_ANY
;
25 server
.sin_port
= htons(2222);
27 if (connect(fd
, (struct sockaddr
*)&server
, sizeof(server
)) == -1)
35 fd
= socket(AF_INET
, SOCK_STREAM
, 0);
42 server
.sin_family
= AF_INET
;
43 server
.sin_addr
.s_addr
= INADDR_ANY
;
44 server
.sin_port
= htons(2222);
46 if (bind(fd
, (const struct sockaddr
*)&server
, sizeof(server
)) == -1) {
54 if (sigemptyset(&set
) == -1) {
61 sfd
= paccept(fd
, (struct sockaddr
*)&client
, &len
, &set
, SOCK_NONBLOCK
);