MCPcopy Create free account
hub / github.com/antirez/smallchat / acceptClient

Function acceptClient

chatlib.c:114–130  ·  view source on GitHub ↗

If the listening socket signaled there is a new connection ready to * be accepted, we accept(2) it and return -1 on error or the new client * socket on success. */

Source from the content-addressed store, hash-verified

112 * be accepted, we accept(2) it and return -1 on error or the new client
113 * socket on success. */
114int acceptClient(int server_socket) {
115 int s;
116
117 while(1) {
118 struct sockaddr_in sa;
119 socklen_t slen = sizeof(sa);
120 s = accept(server_socket,(struct sockaddr*)&sa,&slen);
121 if (s == -1) {
122 if (errno == EINTR)
123 continue; /* Try again. */
124 else
125 return -1;
126 }
127 break;
128 }
129 return s;
130}
131
132/* We also define an allocator that always crashes on out of memory: you
133 * will discover that in most programs designed to run for a long time, that

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected