Lines Matching refs:sock
49 socket_close(int sock) in socket_close() argument
52 close(sock); in socket_close()
62 int sock = socket(AF_INET, type, 0); in socket_loopback_server() local
63 if (sock < 0) { in socket_loopback_server()
73 setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n)); in socket_loopback_server()
75 if (TFR(bind(sock, (struct sockaddr*)&addr, sizeof(addr))) < 0) { in socket_loopback_server()
76 socket_close(sock); in socket_loopback_server()
81 if (TFR(listen(sock, 4)) < 0) { in socket_loopback_server()
82 socket_close(sock); in socket_loopback_server()
87 return sock; in socket_loopback_server()
95 int sock = socket(AF_UNIX, type, 0); in socket_unix_server() local
96 if (sock < 0) { in socket_unix_server()
109 setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n)); in socket_unix_server()
111 if (TFR(bind(sock, (struct sockaddr*)&addr, sizeof(addr))) < 0) { in socket_unix_server()
112 socket_close(sock); in socket_unix_server()
117 if (TFR(listen(sock, 4)) < 0) { in socket_unix_server()
118 socket_close(sock); in socket_unix_server()
123 return sock; in socket_unix_server()
144 int sock, client; in main() local
189 sock = socket_unix_server( path, SOCK_STREAM ); in main()
192 sock = socket_loopback_server( port, SOCK_STREAM ); in main()
194 if (sock < 0) { in main()
201 client = TFR(accept(sock, NULL, NULL)); in main()