Sync and close a socket
| 874 | |
| 875 | // Sync and close a socket |
| 876 | void |
| 877 | iperf_sync_close_socket(int sock) |
| 878 | { |
| 879 | #ifdef HAVE_SOCKET_SHUTDOWN_SHUT_WR |
| 880 | char buffer[128]; |
| 881 | shutdown(sock, SHUT_WR); // Signal that we are done writing |
| 882 | while (Nread(sock, buffer, sizeof(buffer), 0) > 0); // Read until EOF |
| 883 | #else // HAVE_SOCKET_SHUTDOWN_SHUT_WR |
| 884 | sleep(1); // Not the best mechanism, but should be good enough for error cases (and is simple and portable) |
| 885 | #endif // HAVE_SOCKET_SHUTDOWN_SHUT_WR |
| 886 | close(sock); |
| 887 | } |
| 888 |
no test coverage detected
searching dependent graphs…