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

Method get_rw_timeout

lib_acl_cpp/src/stream/stream.cpp:144–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144int stream::get_rw_timeout(bool use_sockopt /* false */) const
145{
146 if (stream_ == NULL) {
147 return -1;
148 }
149
150 if (!use_sockopt) {
151 return stream_->rw_timeout;
152 }
153
154 ACL_SOCKET fd = ACL_VSTREAM_SOCK(stream_);
155
156# if defined(_WIN32) || defined(_WIN64)
157 int timeout = 0, len = sizeof(timeout);
158 if (getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char*) &timeout, &len) < 0) {
159 logger_error("getsockopt SO_RCVTIMEO error=%s, fd=%d",
160 last_serror(), (int) fd);
161 return -1;
162 }
163 return timeout / 1000;
164# else
165 struct timeval tm;
166 memset(&tm, 0, sizeof(tm));
167 socklen_t len = sizeof(tm);
168
169 if (getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tm, &len) < 0) {
170 logger_error("getsockopt SO_RCVTIMEO error=%s, fd=%d",
171 last_serror(), (int) fd);
172 return -1;
173 }
174
175 return (int) tm.tv_sec;
176# endif
177}
178
179ACL_VSTREAM* stream::unbind()
180{

Callers 4

get_objectMethod · 0.80
db_pgsqlMethod · 0.80
pgsql_confMethod · 0.80
mqtt_clientMethod · 0.80

Calls 2

getsockoptFunction · 0.85
last_serrorFunction · 0.50

Tested by

no test coverage detected