MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / set_socket_timeout

Function set_socket_timeout

components/net/utest/tc_sal_socket.c:113–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113static int set_socket_timeout(int sock, int timeout_ms)
114{
115 struct timeval timeout;
116 timeout.tv_sec = timeout_ms / 1000;
117 timeout.tv_usec = (timeout_ms % 1000) * 1000;
118
119 int ret1 = sal_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
120 int ret2 = sal_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout));
121
122 if (ret1 == 0 && ret2 == 0)
123 {
124 LOG_D("Set socket %d timeout to %d ms", sock, timeout_ms);
125 return 0;
126 }
127 else
128 {
129 LOG_W("Failed to set socket %d timeout to %d ms", sock, timeout_ms);
130 return -1;
131 }
132}
133
134static int create_test_socket(int domain, int type, int protocol)
135{

Callers 2

create_test_socketFunction · 0.85
server_thread_entryFunction · 0.85

Calls 1

sal_setsockoptFunction · 0.85

Tested by

no test coverage detected