Home »
Code Examples »
C Code Examples
C - How to set socket timeout when making multiple connections? Code Example
The code for How to set socket timeout when making multiple connections?
struct timeval timeout;
timeout.tv_sec = 10;
timeout.tv_usec = 0;
if (setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout) < 0)
error("setsockopt failed\n");
if (setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof timeout) < 0)
error("setsockopt failed\n");
Code by IncludeHelp,
on August 14, 2022 20:54