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

Function socketSetNonBlockNoDelay

chatlib.c:23–35  ·  view source on GitHub ↗

Set the specified socket in non-blocking mode, with no delay flag. */

Source from the content-addressed store, hash-verified

21
22/* Set the specified socket in non-blocking mode, with no delay flag. */
23int socketSetNonBlockNoDelay(int fd) {
24 int flags, yes = 1;
25
26 /* Set the socket nonblocking.
27 * Note that fcntl(2) for F_GETFL and F_SETFL can't be
28 * interrupted by a signal. */
29 if ((flags = fcntl(fd, F_GETFL)) == -1) return -1;
30 if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) return -1;
31
32 /* This is best-effort. No need to check for errors. */
33 setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes));
34 return 0;
35}
36
37/* Create a TCP socket listening to 'port' ready to accept connections. */
38int createTCPServer(int port) {

Callers 2

TCPConnectFunction · 0.85
createClientFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected