Fixed some bus in Connect()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3592 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -6,7 +6,6 @@
|
|||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
|
|
||||||
#include "wx/setup.h"
|
#include "wx/setup.h"
|
||||||
@@ -200,7 +199,6 @@ void GSocket_Shutdown(GSocket *socket)
|
|||||||
/* If socket has been created, we shutdown it */
|
/* If socket has been created, we shutdown it */
|
||||||
if (socket->m_fd != INVALID_SOCKET)
|
if (socket->m_fd != INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
/* TODO: Guilhem only does this for connection oriented sockets (?) */
|
|
||||||
shutdown(socket->m_fd, 2);
|
shutdown(socket->m_fd, 2);
|
||||||
closesocket(socket->m_fd);
|
closesocket(socket->m_fd);
|
||||||
socket->m_fd = INVALID_SOCKET;
|
socket->m_fd = INVALID_SOCKET;
|
||||||
@@ -420,13 +418,13 @@ GSocket *GSocket_WaitConnection(GSocket *sck)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ioctlsocket(connection->m_fd, FIONBIO, (u_long FAR *) &arg);
|
|
||||||
|
|
||||||
/* Initialize all fields */
|
/* Initialize all fields */
|
||||||
connection->m_server = FALSE;
|
connection->m_server = FALSE;
|
||||||
connection->m_stream = TRUE;
|
connection->m_stream = TRUE;
|
||||||
connection->m_oriented = TRUE;
|
connection->m_oriented = TRUE;
|
||||||
|
|
||||||
|
ioctlsocket(connection->m_fd, FIONBIO, (u_long FAR *) &arg);
|
||||||
|
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,9 +495,8 @@ GSocketError GSocket_SetBroadcast(GSocket *sck)
|
|||||||
/* GSocket_Connect:
|
/* GSocket_Connect:
|
||||||
* Establishes a client connection to a server using the "Peer"
|
* Establishes a client connection to a server using the "Peer"
|
||||||
* field of GSocket. "Peer" must be set by GSocket_SetPeer() before
|
* field of GSocket. "Peer" must be set by GSocket_SetPeer() before
|
||||||
* GSocket_Connect() is called. Possible error codes are GSOCK_INVSOCK
|
* GSocket_Connect() is called. Possible error codes are GSOCK_INVSOCK,
|
||||||
* if the socket is alredy in use, GSOCK_INVADDR if the peer address
|
* GSOCK_INVADDR, GSOCK_TIMEDOUT, GSOCK_WOULDBLOCK and GSOCK_IOERR.
|
||||||
* has not been set, or GSOCK_IOERR for other internal errors.
|
|
||||||
*/
|
*/
|
||||||
GSocketError GSocket_Connect(GSocket *sck, GSocketStream stream)
|
GSocketError GSocket_Connect(GSocket *sck, GSocketStream stream)
|
||||||
{
|
{
|
||||||
@@ -552,13 +549,13 @@ GSocketError GSocket_Connect(GSocket *sck, GSocketStream stream)
|
|||||||
* checking for writability to see if the connection request
|
* checking for writability to see if the connection request
|
||||||
* completes.
|
* completes.
|
||||||
*/
|
*/
|
||||||
if ((err == WSAEWOULDBLOCK) && (sck->m_non_blocking == FALSE))
|
if ((err == WSAEWOULDBLOCK) && (!sck->m_non_blocking))
|
||||||
{
|
{
|
||||||
if (_GSocket_Output_Timeout(sck) == GSOCK_TIMEDOUT)
|
if (_GSocket_Output_Timeout(sck) == GSOCK_TIMEDOUT)
|
||||||
{
|
{
|
||||||
closesocket(sck->m_fd);
|
closesocket(sck->m_fd);
|
||||||
sck->m_fd = INVALID_SOCKET;
|
sck->m_fd = INVALID_SOCKET;
|
||||||
/* sck->m_error is set in _GSocket_Input_Timeout */
|
/* sck->m_error is set in _GSocket_Output_Timeout */
|
||||||
return GSOCK_TIMEDOUT;
|
return GSOCK_TIMEDOUT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -571,7 +568,7 @@ GSocketError GSocket_Connect(GSocket *sck, GSocketStream stream)
|
|||||||
* this way if the connection completes, a GSOCK_CONNECTION
|
* this way if the connection completes, a GSOCK_CONNECTION
|
||||||
* event will be generated, if enabled.
|
* event will be generated, if enabled.
|
||||||
*/
|
*/
|
||||||
if ((err == WSAEWOULDBLOCK) && (sck->m_non_blocking == TRUE))
|
if ((err == WSAEWOULDBLOCK) && (sck->m_non_blocking))
|
||||||
{
|
{
|
||||||
sck->m_error = GSOCK_WOULDBLOCK;
|
sck->m_error = GSOCK_WOULDBLOCK;
|
||||||
return GSOCK_WOULDBLOCK;
|
return GSOCK_WOULDBLOCK;
|
||||||
@@ -807,7 +804,14 @@ LRESULT CALLBACK _GSocket_Internal_WinProc(HWND hWnd,
|
|||||||
case FD_READ: event = GSOCK_INPUT; break;
|
case FD_READ: event = GSOCK_INPUT; break;
|
||||||
case FD_WRITE: event = GSOCK_OUTPUT; break;
|
case FD_WRITE: event = GSOCK_OUTPUT; break;
|
||||||
case FD_ACCEPT: event = GSOCK_CONNECTION; break;
|
case FD_ACCEPT: event = GSOCK_CONNECTION; break;
|
||||||
case FD_CONNECT: event = GSOCK_CONNECTION; break;
|
case FD_CONNECT:
|
||||||
|
{
|
||||||
|
if (WSAGETSELECTERROR(lParam) != 0)
|
||||||
|
event = GSOCK_LOST;
|
||||||
|
else
|
||||||
|
event = GSOCK_CONNECTION;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case FD_CLOSE: event = GSOCK_LOST; break;
|
case FD_CLOSE: event = GSOCK_LOST; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -839,7 +843,7 @@ GSocketError _GSocket_Input_Timeout(GSocket *socket)
|
|||||||
{
|
{
|
||||||
fd_set readfds;
|
fd_set readfds;
|
||||||
|
|
||||||
if (socket->m_non_blocking == FALSE)
|
if (!socket->m_non_blocking)
|
||||||
{
|
{
|
||||||
FD_ZERO(&readfds);
|
FD_ZERO(&readfds);
|
||||||
FD_SET(socket->m_fd, &readfds);
|
FD_SET(socket->m_fd, &readfds);
|
||||||
@@ -860,7 +864,7 @@ GSocketError _GSocket_Output_Timeout(GSocket *socket)
|
|||||||
{
|
{
|
||||||
fd_set writefds;
|
fd_set writefds;
|
||||||
|
|
||||||
if (socket->m_non_blocking == FALSE)
|
if (!socket->m_non_blocking)
|
||||||
{
|
{
|
||||||
FD_ZERO(&writefds);
|
FD_ZERO(&writefds);
|
||||||
FD_SET(socket->m_fd, &writefds);
|
FD_SET(socket->m_fd, &writefds);
|
||||||
@@ -924,8 +928,8 @@ int _GSocket_Recv_Dgram(GSocket *socket, char *buffer, int size)
|
|||||||
}
|
}
|
||||||
if (_GAddress_translate_from(socket->m_peer, &from, fromlen) != GSOCK_NOERROR)
|
if (_GAddress_translate_from(socket->m_peer, &from, fromlen) != GSOCK_NOERROR)
|
||||||
{
|
{
|
||||||
socket->m_error = GSOCK_MEMERR; /* TODO: bug in Unix GSocket! */
|
socket->m_error = GSOCK_MEMERR;
|
||||||
GAddress_destroy(socket->m_peer); /* TODO: bug in Unix GSocket! */
|
GAddress_destroy(socket->m_peer);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user