| 132 | } |
| 133 | |
| 134 | static 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 | |
| 158 | static void close_test_socket(int sock) |
| 159 | { |
no test coverage detected