From 5f814f27d91430baa0d7f43ba92c45060da2b91c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 30 Mar 2007 19:04:25 +0000 Subject: [PATCH] don't handle orderly socket shutdown by the peer as an error (patch 1688222) [backport from HEAD] git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45171 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 4 ++++ src/unix/gsocket.cpp | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index b2d864755f..b122f1f371 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -91,6 +91,10 @@ Major new features in 2.8 release 2.8.4 ----- +All (Unix): + +- Handle socket shutdown by the peer correctly in wxSocket (Tim Kosse) + wxMSW: - Corrected wxStaticBox label appearance when its foreground colour was set: diff --git a/src/unix/gsocket.cpp b/src/unix/gsocket.cpp index eeee3fa8cc..659f709be5 100644 --- a/src/unix/gsocket.cpp +++ b/src/unix/gsocket.cpp @@ -1168,17 +1168,16 @@ int GSocket::Read(char *buffer, int size) else ret = Recv_Dgram(buffer, size); - /* If recv returned zero, then the connection is lost, and errno is not set. + /* If recv returned zero, then the connection has been gracefully closed. * Otherwise, recv has returned an error (-1), in which case we have lost the * socket only if errno does _not_ indicate that there may be more data to read. */ if (ret == 0) { - m_error = GSOCK_IOERR; + /* Make sure wxSOCKET_LOST event gets sent and shut down the socket */ m_detected = GSOCK_LOST_FLAG; - Close(); - // Signal an error for return - return -1; + Detected_Read(); + return 0; } else if (ret == -1) {