From f4854380c1b7c0d72fc78ad47220f42fb05d7b17 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 30 Mar 2007 19:02:30 +0000 Subject: [PATCH] don't handle orderly socket shutdown by the peer as an error (patch 1688222) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45170 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 b4178c01a5..dc0d82cff7 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -116,6 +116,10 @@ wxMSW: 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) { -- 2.45.2