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

Function create_test_socket

components/net/utest/tc_sal_socket.c:134–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134static int create_test_socket(int domain, int type, int protocol)
135{
136 int sock = sal_socket(domain, type, protocol);
137 if (sock >= 0)
138 {
139 LOG_I("Created socket %d (domain=%d, type=%d, protocol=%d)", sock, domain, type, protocol);
140 /* Set timeout for all socket operations to prevent blocking */
141 if (set_socket_timeout(sock, SOCKET_TIMEOUT_MS) != 0)
142 {
143 LOG_W("Failed to set timeout for socket %d", sock);
144 }
145
146 /* Enable SO_REUSEADDR to allow reusing ports and avoid bind failures due to TIME_WAIT */
147 int opt = 1;
148 sal_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
149 LOG_D("Enabled SO_REUSEADDR for socket %d", sock);
150 }
151 else
152 {
153 LOG_E("Failed to create socket (domain=%d, type=%d, protocol=%d)", domain, type, protocol);
154 }
155 return sock;
156}
157
158static void close_test_socket(int sock)
159{

Callers 10

server_thread_entryFunction · 0.85
client_thread_entryFunction · 0.85
TC_sal_socket_bindFunction · 0.85
TC_sal_socket_listenFunction · 0.85
TC_sal_socket_connectFunction · 0.85
TC_sal_socket_acceptFunction · 0.85
TC_sal_socket_send_recvFunction · 0.85
TC_sal_socket_closeFunction · 0.85

Calls 3

set_socket_timeoutFunction · 0.85
sal_setsockoptFunction · 0.85
sal_socketFunction · 0.50

Tested by

no test coverage detected