MCPcopy Create free account
hub / github.com/esnet/iperf / iperf_sync_close_socket

Function iperf_sync_close_socket

src/net.c:876–887  ·  view source on GitHub ↗

Sync and close a socket

Source from the content-addressed store, hash-verified

874
875// Sync and close a socket
876void
877iperf_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

Callers 2

iperf_client_endFunction · 0.85
cleanup_serverFunction · 0.85

Calls 1

NreadFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…