From 976abb72fc2a94bf38c9231690ebeabc7631e491 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 24 Sep 2005 22:31:55 +0000 Subject: [PATCH] set error to GSOCK_TIMEOUT if the socket timed out (modified and extended patch 1303554) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35666 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/gsocket.cpp | 3 +++ src/unix/gsocket.cpp | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/msw/gsocket.cpp b/src/msw/gsocket.cpp index 1fcf0afa6d..ac350bc4ce 100644 --- a/src/msw/gsocket.cpp +++ b/src/msw/gsocket.cpp @@ -726,7 +726,10 @@ int GSocket::Read(char *buffer, int size) /* If the socket is blocking, wait for data (with a timeout) */ if (Input_Timeout() == GSOCK_TIMEDOUT) + { + m_error = GSOCK_TIMEDOUT; return -1; + } /* Read the data */ if (m_stream) diff --git a/src/unix/gsocket.cpp b/src/unix/gsocket.cpp index becd67f59c..d9a83d361e 100644 --- a/src/unix/gsocket.cpp +++ b/src/unix/gsocket.cpp @@ -869,23 +869,25 @@ int GSocket::Read(char *buffer, int size) Disable(GSOCK_INPUT); /* If the socket is blocking, wait for data (with a timeout) */ - if (Input_Timeout() == GSOCK_TIMEDOUT) - /* We no longer return here immediately, otherwise socket events would not be re-enabled! */ + if (Input_Timeout() == GSOCK_TIMEDOUT) { + m_error = GSOCK_TIMEDOUT; + /* Don't return here immediately, otherwise socket events would not be + * re-enabled! */ ret = -1; + } else { /* Read the data */ if (m_stream) ret = Recv_Stream(buffer, size); else ret = Recv_Dgram(buffer, size); - } - if (ret == -1) - { - if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) - m_error = GSOCK_WOULDBLOCK; - else - m_error = GSOCK_IOERR; + if (ret == -1) { + if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) + m_error = GSOCK_WOULDBLOCK; + else + m_error = GSOCK_IOERR; + } } /* Enable events again now that we are done processing */ -- 2.47.2