X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0d34c30e5535d496c2b08bea971a8abb4a1b34da..7a7bd38a77d46e5d45fa6bbff2331335cb38579c:/src/unix/gsocket.cpp diff --git a/src/unix/gsocket.cpp b/src/unix/gsocket.cpp index 862e94c989..d9a83d361e 100644 --- a/src/unix/gsocket.cpp +++ b/src/unix/gsocket.cpp @@ -722,7 +722,8 @@ GSocketError GSocket::Connect(GSocketStream stream) * connection _if_ blocking sockets are being used. * If connect above returns 0, we are already connected and need to make the * call to Enable_Events now. - + */ + if (m_non_blocking || ret == 0) { gs_gui_functions->Enable_Events(this); @@ -868,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 */