Set the socket send timeout (SO_SNDTIMEO socket option) to the specified * number of milliseconds, or disable it if the 'ms' argument is zero. */
| 199 | /* Set the socket send timeout (SO_SNDTIMEO socket option) to the specified |
| 200 | * number of milliseconds, or disable it if the 'ms' argument is zero. */ |
| 201 | int anetSendTimeout(char *err, int fd, long long ms) { |
| 202 | struct timeval tv; |
| 203 | |
| 204 | tv.tv_sec = ms/1000; |
| 205 | tv.tv_usec = (ms%1000)*1000; |
| 206 | if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1) { |
| 207 | anetSetError(err, "setsockopt SO_SNDTIMEO: %s", strerror(errno)); |
| 208 | return ANET_ERR; |
| 209 | } |
| 210 | return ANET_OK; |
| 211 | } |
| 212 | |
| 213 | /* Set the socket receive timeout (SO_RCVTIMEO socket option) to the specified |
| 214 | * number of milliseconds, or disable it if the 'ms' argument is zero. */ |
no test coverage detected