MCPcopy Create free account
hub / github.com/acl-dev/acl / set_sockopt_timeo

Function set_sockopt_timeo

lib_acl_cpp/src/stream/stream.cpp:74–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74static bool set_sockopt_timeo(ACL_SOCKET fd, int opt, int timeout)
75{
76 if (timeout <= 0) {
77 return true;
78 }
79
80# if defined(_WIN32) || defined(_WIN64)
81 timeout *= 1000; // From seconds to millisecond.
82 if (setsockopt(fd, SOL_SOCKET, opt, (const char*) &timeout, sizeof(timeout)) < 0) {
83 logger_error("setsockopt error=%s, timeout=%d, opt=%d, fd=%d",
84 last_serror(), timeout, opt, (int) fd);
85 return false;
86 }
87# else // Must be Linux or __APPLE__.
88 struct timeval tm;
89 tm.tv_sec = timeout;
90 tm.tv_usec = 0;
91
92 if (setsockopt(fd, SOL_SOCKET, opt, &tm, sizeof(tm)) < 0) {
93 logger_error("setsockopt error=%s, timeout=%d, opt=%d, fd=%d",
94 last_serror(), timeout, opt, (int) fd);
95 return false;
96 }
97# endif
98
99 return true;
100}
101
102bool stream::set_rw_timeout(int n, bool use_sockopt /* false */)
103{

Callers 1

set_rw_timeoutMethod · 0.85

Calls 2

setsockoptFunction · 0.85
last_serrorFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…