Set the specified socket in non-blocking mode, with no delay flag. */
| 21 | |
| 22 | /* Set the specified socket in non-blocking mode, with no delay flag. */ |
| 23 | int 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. */ |
| 38 | int createTCPServer(int port) { |
no outgoing calls
no test coverage detected