Outgoing connections now work on Windows too.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2475 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -132,7 +132,6 @@ ConnectState_getExtra(ConnectState *connectState) {
|
||||
return connectState->extra;
|
||||
}
|
||||
|
||||
// Try connecting to the next address.
|
||||
static void
|
||||
connectCallback(NetDescriptor *nd) {
|
||||
// Called by the NetManager when a connection has been established.
|
||||
@@ -207,6 +206,7 @@ setConnectTimeout(ConnectState *connectState) {
|
||||
(AlarmCallback) connectTimeoutCallback, connectState);
|
||||
}
|
||||
|
||||
// Try connecting to the next address.
|
||||
static Socket *
|
||||
tryConnectHostNext(ConnectState *connectState) {
|
||||
struct addrinfo *info;
|
||||
|
||||
@@ -112,7 +112,7 @@ NetManager_addDesc(NetDescriptor *nd) {
|
||||
eventMask |= FD_READ | FD_ACCEPT;
|
||||
|
||||
if (nd->writeCallback != NULL)
|
||||
eventMask |= FD_WRITE | FD_CONNECT;
|
||||
eventMask |= FD_WRITE /* | FD_CONNECT */;
|
||||
|
||||
if (nd->exceptionCallback != NULL)
|
||||
eventMask |= FD_OOB;
|
||||
@@ -299,12 +299,12 @@ NetManager_deactivateReadCallback(NetDescriptor *nd) {
|
||||
|
||||
void
|
||||
NetManager_activateWriteCallback(NetDescriptor *nd) {
|
||||
activateSomeCallback(nd, FD_WRITE | FD_CONNECT);
|
||||
activateSomeCallback(nd, FD_WRITE /* | FD_CONNECT */);
|
||||
}
|
||||
|
||||
void
|
||||
NetManager_deactivateWriteCallback(NetDescriptor *nd) {
|
||||
deactivateSomeCallback(nd, FD_WRITE | FD_CONNECT);
|
||||
deactivateSomeCallback(nd, FD_WRITE /* | FD_CONNECT */);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -376,6 +376,9 @@ NetManager_processEvent(size_t index) {
|
||||
if (closed)
|
||||
goto closed;
|
||||
}
|
||||
#if 0
|
||||
// No need for this. Windows also sets FD_WRITE in this case, and
|
||||
// writability is what we check for anyhow.
|
||||
if (networkEvents.lNetworkEvents & FD_CONNECT) {
|
||||
// There is no specific connect callback (because the BSD sockets
|
||||
// don't work with specific notification for connect); we use
|
||||
@@ -390,6 +393,7 @@ NetManager_processEvent(size_t index) {
|
||||
if (closed)
|
||||
goto closed;
|
||||
}
|
||||
#endif
|
||||
if (networkEvents.lNetworkEvents & FD_CLOSE) {
|
||||
// The close event is handled last, in case there was still
|
||||
// data in the buffers which could be processed.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "port.h"
|
||||
|
||||
#if defined (USE_WINSOCK)
|
||||
#ifdef USE_WINSOCK
|
||||
int winsockErrorToErrno(int winsockError);
|
||||
int getWinsockErrno(void);
|
||||
# define EAI_SYSTEM 0x02000001
|
||||
|
||||
@@ -88,6 +88,13 @@ Socket_connect(Socket *sock, const struct sockaddr *addr,
|
||||
errno = getWinsockErrno();
|
||||
} while (errno == EINTR);
|
||||
|
||||
if (errno == EWOULDBLOCK) {
|
||||
// Windows returns (WSA)EWOULDBLOCK when a connection is being
|
||||
// initiated on a non-blocking socket, while other platforms
|
||||
// use EINPROGRESS in such cases.
|
||||
errno = EINPROGRESS;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user