X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9bf10d6bd3df0d5ad9d9849f162b17a62c3ac51f..8290d43d0d43369d007f1c47abf98a45da461a30:/src/unix/gsocket.c diff --git a/src/unix/gsocket.c b/src/unix/gsocket.c index b95eda0462..5b3c647893 100644 --- a/src/unix/gsocket.c +++ b/src/unix/gsocket.c @@ -25,7 +25,7 @@ #ifdef __VMS__ #include -struct sockaddr_un { +struct sockaddr_un { u_char sun_len; /* sockaddr len including null */ u_char sun_family; /* AF_UNIX */ char sun_path[108]; /* path name (gag) */ @@ -53,7 +53,6 @@ struct sockaddr_un { #endif #include - #ifndef SOCKLEN_T #ifdef VMS @@ -92,16 +91,25 @@ struct sockaddr_un { #ifndef __GSOCKET_STANDALONE__ -#include "wx/gsocket.h" #include "wx/unix/gsockunx.h" +#include "wx/gsocket.h" #else -#include "gsocket.h" #include "gsockunx.h" +#include "gsocket.h" #endif /* __GSOCKET_STANDALONE__ */ +/* redefine some GUI-only functions to do nothing in console mode */ +#if defined(wxUSE_GUI) && !wxUSE_GUI + #define _GSocket_GUI_Init(socket) + #define _GSocket_GUI_Destroy(socket) + #define _GSocket_Enable_Events(socket) + #define _GSocket_Disable_Events(socket) + #define _GSocket_Install_Callback(socket, event) + #define _GSocket_Uninstall_Callback(socket, event) +#endif /* wxUSE_GUI */ /* Global initialisers */ @@ -193,7 +201,7 @@ void GSocket_Shutdown(GSocket *socket) for (evt = 0; evt < GSOCK_MAX_EVENT; evt++) socket->m_cbacks[evt] = NULL; - socket->m_detected = 0; + socket->m_detected = GSOCK_LOST_FLAG; _GSocket_Disable_Events(socket); } @@ -706,6 +714,8 @@ int GSocket_Write(GSocket *socket, const char *buffer, int size) int ret; assert(socket != NULL); + + printf( "GSocket_Write #1, size %d\n", size ); if (socket->m_fd == -1 || socket->m_server) { @@ -713,16 +723,22 @@ int GSocket_Write(GSocket *socket, const char *buffer, int size) return -1; } + printf( "GSocket_Write #2, size %d\n", size ); + /* If the socket is blocking, wait for writability (with a timeout) */ if (_GSocket_Output_Timeout(socket) == GSOCK_TIMEDOUT) return -1; + printf( "GSocket_Write #3, size %d\n", size ); + /* Write the data */ if (socket->m_stream) ret = _GSocket_Send_Stream(socket, buffer, size); else ret = _GSocket_Send_Dgram(socket, buffer, size); + printf( "GSocket_Write #4, size %d\n", size ); + if (ret == -1) { if (errno == EWOULDBLOCK) @@ -739,6 +755,8 @@ int GSocket_Write(GSocket *socket, const char *buffer, int size) return -1; } + printf( "GSocket_Write #5, size %d ret %d\n", size, ret ); + return ret; } @@ -753,7 +771,7 @@ GSocketEventFlags GSocket_Select(GSocket *socket, GSocketEventFlags flags) { assert(socket != NULL); - return (flags & socket->m_detected); + return flags & socket->m_detected; } /* Flags */ @@ -933,13 +951,7 @@ GSocketError _GSocket_Output_Timeout(GSocket *socket) int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size) { - int ret; - - MASK_SIGNAL(); - ret = recv(socket->m_fd, buffer, size, 0); - UNMASK_SIGNAL(); - - return ret; + return recv(socket->m_fd, buffer, size, 0); } int _GSocket_Recv_Dgram(GSocket *socket, char *buffer, int size) @@ -951,9 +963,7 @@ int _GSocket_Recv_Dgram(GSocket *socket, char *buffer, int size) fromlen = sizeof(from); - MASK_SIGNAL(); ret = recvfrom(socket->m_fd, buffer, size, 0, &from, (SOCKLEN_T *) &fromlen); - UNMASK_SIGNAL(); if (ret == -1) return -1;