mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-16 18:10:40 -04:00
Change some code according G10h4ck remarks.
This commit is contained in:
parent
7755f85c4c
commit
91a35f4a21
9 changed files with 242 additions and 212 deletions
|
@ -174,3 +174,17 @@ std::string rs_inet_ntoa(struct in_addr in)
|
|||
rs_sprintf(str, "%u.%u.%u.%u", (int) bytes[0], (int) bytes[1], (int) bytes[2], (int) bytes[3]);
|
||||
return str;
|
||||
}
|
||||
|
||||
int rs_setSockTimeout( int sockfd, bool forReceive /*= true*/
|
||||
, int timeout_Sec /*= 0*/, int timeout_uSec /*= 0*/)
|
||||
{
|
||||
#ifdef WINDOWS_SYS
|
||||
DWORD timeout = timeout_Sec * 1000 + timeout_uSec;
|
||||
#else
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = timeout_Sec;
|
||||
timeout.tv_usec = timeout_uSec;
|
||||
#endif
|
||||
return setsockopt( sockfd, SOL_SOCKET, forReceive ? SO_RCVTIMEO : SO_SNDTIMEO
|
||||
, (const char*)&timeout, sizeof timeout);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue