Helper: Set socket to non-blocking mode
| 137 | |
| 138 | // Helper: Set socket to non-blocking mode |
| 139 | bool set_nonblocking(int fd) { |
| 140 | #ifdef FL_IS_WIN |
| 141 | u_long mode = 1; |
| 142 | return ioctlsocket(fd, FIONBIO, &mode) == 0; |
| 143 | #else |
| 144 | int flags = fcntl(fd, F_GETFL, 0); |
| 145 | if (flags == -1) return false; |
| 146 | return fcntl(fd, F_SETFL, flags | O_NONBLOCK) != -1; |
| 147 | #endif |
| 148 | } |
| 149 | |
| 150 | } // anonymous namespace |
| 151 |
no test coverage detected