diff --git a/network/network.cc b/network/network.cc index 37e8e5120..0d74f9a6e 100644 --- a/network/network.cc +++ b/network/network.cc @@ -675,6 +675,12 @@ void network_send_server(network_command_t* nwc ) bool network_send_data( SOCKET dest, const char *buf, const uint16 size, uint16 &count, const int timeout_ms ) { count = 0; + + #if USE_WINSOCK == 0 + // ignore SIGPIPE sent by send() function. + signal(SIGPIPE, SIG_IGN); + #endif + while (count < size) { int sent = send(dest, buf+count, size-count, 0); if (sent == -1) { @@ -711,6 +717,11 @@ bool network_send_data( SOCKET dest, const char *buf, const uint16 size, uint16 count += sent; DBG_DEBUG4("network_send_data", "sent %d bytes to socket[%d]; size=%d, left=%d", count, dest, size, size-count ); } + + #if USE_WINSOCK == 0 + signal(SIGPIPE, SIG_DFL); + #endif + // we reach here only if data are sent completely return true; }