MCPcopy Create free account
hub / github.com/F-Stack/f-stack / anetRecvTimeout

Function anetRecvTimeout

app/redis-6.2.6/src/anet.c:215–225  ·  view source on GitHub ↗

Set the socket receive timeout (SO_RCVTIMEO socket option) to the specified * number of milliseconds, or disable it if the 'ms' argument is zero. */

Source from the content-addressed store, hash-verified

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. */
215int 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".

Callers 3

setBlockingTimeoutFunction · 0.85
unsetBlockingTimeoutFunction · 0.85
connRecvTimeoutFunction · 0.85

Calls 2

anetSetErrorFunction · 0.85
setsockoptFunction · 0.70

Tested by

no test coverage detected