| 111 | } |
| 112 | |
| 113 | static 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 | |
| 134 | static int create_test_socket(int domain, int type, int protocol) |
| 135 | { |
no test coverage detected