From 9592b68708c0583398d0a03295a81f4e3e2b3087 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Sat, 31 Jul 1999 13:33:01 +0000 Subject: [PATCH] Converted some SetBlocking to SetNonBlocking git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3225 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/unix/gsocket.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/unix/gsocket.c b/src/unix/gsocket.c index a49a146bb9..9ab270d19b 100644 --- a/src/unix/gsocket.c +++ b/src/unix/gsocket.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -343,7 +344,7 @@ GSocketError GSocket_SetNonOriented(GSocket *sck) return GSOCK_IOERR; } - GSocket_SetBlocking(sck, sck->m_blocking); + GSocket_SetNonBlocking(sck, sck->m_blocking); GSocket_SetTimeout(sck, sck->m_timeout); return GSOCK_NOERROR; @@ -401,7 +402,7 @@ GSocketError GSocket_Connect(GSocket *sck, GSocketStream stream) /* It is not a server */ sck->m_server = FALSE; - GSocket_SetBlocking(sck, sck->m_blocking); + GSocket_SetNonBlocking(sck, sck->m_blocking); GSocket_SetTimeout(sck, sck->m_timeout); return GSOCK_NOERROR; @@ -613,10 +614,14 @@ int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size) MASK_SIGNAL(); ret = recv(socket->m_fd, buffer, size, 0); UNMASK_SIGNAL(); - if (ret == -1) { + if (ret == -1 && errno != EAGAIN) { socket->m_error = GSOCK_IOERR; return -1; } + if (errno == EAGAIN) { + socket->m_error = GSOCK_TRYAGAIN; + return -1; + } return ret; } @@ -631,10 +636,14 @@ int _GSocket_Recv_Dgram(GSocket *socket, char *buffer, int size) MASK_SIGNAL(); ret = recvfrom(socket->m_fd, buffer, size, 0, &from, &fromlen); UNMASK_SIGNAL(); - if (ret == -1) { + if (ret == -1 && errno != EAGAIN) { socket->m_error = GSOCK_IOERR; return -1; } + if (errno == EAGAIN) { + socket->m_error = GSOCK_TRYAGAIN; + return -1; + } /* Translate a system address into a GSocket address */ if (!socket->m_peer) @@ -651,10 +660,14 @@ int _GSocket_Send_Stream(GSocket *socket, const char *buffer, int size) MASK_SIGNAL(); ret = send(socket->m_fd, buffer, size, 0); UNMASK_SIGNAL(); - if (ret == -1) { + if (ret == -1 && errno != EAGAIN) { socket->m_error = GSOCK_IOERR; return -1; } + if (errno == EAGAIN) { + socket->m_error = GSOCK_TRYAGAIN; + return -1; + } return ret; } @@ -673,14 +686,19 @@ int _GSocket_Send_Dgram(GSocket *socket, const char *buffer, int size) MASK_SIGNAL(); ret = sendto(socket->m_fd, buffer, size, 0, addr, len); UNMASK_SIGNAL(); - if (ret == -1) { - socket->m_error = GSOCK_IOERR; - return -1; - } /* Frees memory allocated from _GAddress_translate_to */ free(addr); + if (ret == -1 && errno != EAGAIN) { + socket->m_error = GSOCK_IOERR; + return -1; + } + if (errno == EAGAIN) { + socket->m_error = GSOCK_TRYAGAIN; + return -1; + } + return ret; } -- 2.45.2