_W("Retry to connect to %s. count(%d)", path.c_str(), retry);
}
- if (timeout > 0) {
- time_t sec = timeout / 1000;
- suseconds_t usec = (timeout - sec * 1000) * 1000;
- struct timeval tv = { sec, usec };
- int ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
- if (ret < 0) {
- _E("setsockopt(SO_RCVTIMEO) is failed. fd(%d), errno(%d)", fd, errno);
- close(fd);
- return nullptr;
- }
+ if (timeout <= 0) {
+ _W("Use default timeout");
+ timeout = 5000;
+ }
+
+ time_t sec = timeout / 1000;
+ suseconds_t usec = (timeout - sec * 1000) * 1000;
+ struct timeval tv = { sec, usec };
+ int ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ if (ret < 0) {
+ _E("setsockopt(SO_RCVTIMEO) is failed. fd(%d), errno(%d)", fd, errno);
+ close(fd);
+ return nullptr;
}
return new (std::nothrow) Client(fd);