Set the socket receive timeout (SO_RCVTIMEO socket option) to the specified * number of milliseconds, or disable it if the 'ms' argument is zero. */
| 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. */ |
| 215 | int anetRecvTimeout(char *err, int fd, long long ms) { |
| 216 | struct timeval tv; |
| 217 | |
| 218 | tv.tv_sec = ms/1000; |
| 219 | tv.tv_usec = (ms%1000)*1000; |
| 220 | if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) { |
| 221 | anetSetError(err, "setsockopt SO_RCVTIMEO: %s", strerror(errno)); |
| 222 | return ANET_ERR; |
| 223 | } |
| 224 | return ANET_OK; |
| 225 | } |
| 226 | |
| 227 | /* Resolve the hostname "host" and set the string representation of the |
| 228 | * IP address into the buffer pointed by "ipbuf". |
no test coverage detected