X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6afe7fdf1de812bbc656a1ef832088e56412ae3..7f10ed6e65f6281b8d587a6382f198c8a394db97:/src/msw/gsocket.cpp diff --git a/src/msw/gsocket.cpp b/src/msw/gsocket.cpp index 83fb30a935..42873e0858 100644 --- a/src/msw/gsocket.cpp +++ b/src/msw/gsocket.cpp @@ -1,10 +1,12 @@ /* ------------------------------------------------------------------------- - * Project: GSocket (Generic Socket) - * Name: gsocket.cpp - * Author: Guillermo Rodriguez Garcia - * Purpose: GSocket main MSW file - * Licence: The wxWindows licence - * CVSID: $Id$ + * Project: GSocket (Generic Socket) + * Name: src/msw/gsocket.cpp + * Copyright: (c) Guilhem Lavaux + * Licence: wxWindows Licence + * Author: Guillermo Rodriguez Garcia + * Purpose: GSocket main MSW file + * Licence: The wxWindows licence + * CVSID: $Id$ * ------------------------------------------------------------------------- */ @@ -53,7 +55,6 @@ #ifndef __GSOCKET_STANDALONE__ # include "wx/platform.h" -# include "wx/setup.h" #endif #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) @@ -82,9 +83,9 @@ #include #include -/* if we use configure for MSW SOCKLEN_T will be already defined */ -#ifndef SOCKLEN_T -# define SOCKLEN_T int +/* if we use configure for MSW WX_SOCKLEN_T will be already defined */ +#ifndef WX_SOCKLEN_T +# define WX_SOCKLEN_T int #endif /* Table of GUI-related functions. We must call them indirectly because @@ -297,7 +298,7 @@ GAddress *GSocket::GetLocal() { GAddress *address; struct sockaddr addr; - SOCKLEN_T size = sizeof(addr); + WX_SOCKLEN_T size = sizeof(addr); GSocketError err; assert(this); @@ -409,7 +410,7 @@ GSocketError GSocket::SetServer() if ((bind(m_fd, m_local->m_addr, m_local->m_len) != 0) || (getsockname(m_fd, m_local->m_addr, - (SOCKLEN_T *)&m_local->m_len) != 0) || + (WX_SOCKLEN_T *)&m_local->m_len) != 0) || (listen(m_fd, 5) != 0)) { Close(); @@ -436,7 +437,7 @@ GSocket *GSocket::WaitConnection() { GSocket *connection; struct sockaddr from; - SOCKLEN_T fromlen = sizeof(from); + WX_SOCKLEN_T fromlen = sizeof(from); GSocketError err; u_long arg = 1; @@ -514,7 +515,7 @@ GSocket *GSocket::WaitConnection() * make the appropriate setsockopt() call. * Implemented as a GSocket function because clients (ie, wxSocketServer) * don't have access to the GSocket struct information. -* Returns true if the flag was set correctly, false if an error occured +* Returns true if the flag was set correctly, false if an error occurred * (ie, if the parameter was NULL) */ bool GSocket::SetReusable() @@ -533,7 +534,7 @@ bool GSocket::SetReusable() * For stream (connection oriented) sockets, GSocket_Connect() tries * to establish a client connection to a server using the peer address * as established with GSocket_SetPeer(). Returns GSOCK_NOERROR if the - * connection has been succesfully established, or one of the error + * connection has been successfully established, or one of the error * codes listed below. Note that for nonblocking sockets, a return * value of GSOCK_WOULDBLOCK doesn't mean a failure. The connection * request can be completed later; you should use GSocket_Select() @@ -694,7 +695,7 @@ GSocketError GSocket::SetNonOriented() if ((bind(m_fd, m_local->m_addr, m_local->m_len) != 0) || (getsockname(m_fd, m_local->m_addr, - (SOCKLEN_T *)&m_local->m_len) != 0)) + (WX_SOCKLEN_T *)&m_local->m_len) != 0)) { Close(); m_error = GSOCK_IOERR; @@ -724,7 +725,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) @@ -865,7 +869,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags) if (m_establishing && !m_server) { int error; - SOCKLEN_T len = sizeof(error); + WX_SOCKLEN_T len = sizeof(error); m_establishing = false; @@ -935,7 +939,7 @@ void GSocket::SetTimeout(unsigned long millis) } /* GSocket_GetError: - * Returns the last error occured for this socket. Note that successful + * Returns the last error occurred for this socket. Note that successful * operations do not clear this back to GSOCK_NOERROR, so use it only * after an error. */ @@ -960,7 +964,7 @@ GSocketError WXDLLIMPEXP_NET GSocket::GetError() * assume that it can write since the first OUTPUT event, and no more * OUTPUT events will be generated unless an error occurs. * GSOCK_CONNECTION: - * Connection succesfully established, for client sockets, or incoming + * Connection successfully established, for client sockets, or incoming * client connection, for server sockets. Wait for this event (also watch * out for GSOCK_LOST) after you issue a nonblocking GSocket_Connect() call. * GSOCK_LOST: @@ -1112,7 +1116,7 @@ int GSocket::Recv_Stream(char *buffer, int size) int GSocket::Recv_Dgram(char *buffer, int size) { struct sockaddr from; - SOCKLEN_T fromlen = sizeof(from); + WX_SOCKLEN_T fromlen = sizeof(from); int ret; GSocketError err; @@ -1418,7 +1422,7 @@ GSocketError GAddress_INET_SetHostAddress(GAddress *address, CHECK_ADDRESS(address, INET); addr = &(((struct sockaddr_in *)address->m_addr)->sin_addr); - addr->s_addr = htonl(hostaddr);; + addr->s_addr = htonl(hostaddr); return GSOCK_NOERROR; } @@ -1557,4 +1561,3 @@ GSocketError GAddress_UNIX_GetPath(GAddress *address, char *WXUNUSED(path), size typedef void (*wxDummy)(); #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */ -