diff --git a/src/network/connection.c b/src/network/connection.c index 6de5f54..f9f2cdc 100644 --- a/src/network/connection.c +++ b/src/network/connection.c @@ -156,7 +156,13 @@ ssize_t net_con_send(struct net_connection* con, const void* buf, size_t len) ret = net_send(con->sd, buf, len, UHUB_SEND_SIGNAL); if (ret == -1) { - if (net_error() == EWOULDBLOCK || net_error() == EINTR) + if ( +#ifdef WINSOCK + net_error() == WSAEWOULDBLOCK +#else + net_error() == EWOULDBLOCK +#endif + || net_error() == EINTR) return 0; return -1; } @@ -190,7 +196,13 @@ ssize_t net_con_recv(struct net_connection* con, void* buf, size_t len) ret = net_recv(con->sd, buf, len, 0); if (ret == -1) { - if (net_error() == EWOULDBLOCK || net_error() == EINTR) + if ( +#ifdef WINSOCK + net_error() == WSAEWOULDBLOCK +#else + net_error() == EWOULDBLOCK +#endif + || net_error() == EINTR) return 0; return -net_error(); } @@ -226,7 +238,13 @@ ssize_t net_con_peek(struct net_connection* con, void* buf, size_t len) int ret = net_recv(con->sd, buf, len, MSG_PEEK); if (ret == -1) { - if (net_error() == EWOULDBLOCK || net_error() == EINTR) + if ( +#ifdef WINSOCK + net_error() == WSAEWOULDBLOCK +#else + net_error() == EWOULDBLOCK +#endif + || net_error() == EINTR) return 0; return -net_error(); } diff --git a/src/system.h b/src/system.h index bdbf34f..baf089b 100644 --- a/src/system.h +++ b/src/system.h @@ -36,6 +36,11 @@ #endif #endif +#if defined(__CYGWIN__) || defined(__MINGW32__) +#define HAVE_SSIZE_T +#define NEED_GETOPT +#endif + #ifdef WINSOCK #ifndef FD_SETSIZE #define FD_SETSIZE 4096