|
@@ -27,7 +27,9 @@ HV_INLINE int socket_errno() {
|
|
|
HV_EXPORT const char* socket_strerror(int err);
|
|
HV_EXPORT const char* socket_strerror(int err);
|
|
|
|
|
|
|
|
#ifdef OS_WIN
|
|
#ifdef OS_WIN
|
|
|
|
|
+
|
|
|
typedef int socklen_t;
|
|
typedef int socklen_t;
|
|
|
|
|
+
|
|
|
HV_INLINE int blocking(int sockfd) {
|
|
HV_INLINE int blocking(int sockfd) {
|
|
|
unsigned long nb = 0;
|
|
unsigned long nb = 0;
|
|
|
return ioctlsocket(sockfd, FIONBIO, &nb);
|
|
return ioctlsocket(sockfd, FIONBIO, &nb);
|
|
@@ -36,19 +38,32 @@ HV_INLINE int nonblocking(int sockfd) {
|
|
|
unsigned long nb = 1;
|
|
unsigned long nb = 1;
|
|
|
return ioctlsocket(sockfd, FIONBIO, &nb);
|
|
return ioctlsocket(sockfd, FIONBIO, &nb);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+#ifndef poll
|
|
|
#define poll WSAPoll
|
|
#define poll WSAPoll
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
#undef EAGAIN
|
|
#undef EAGAIN
|
|
|
#define EAGAIN WSAEWOULDBLOCK
|
|
#define EAGAIN WSAEWOULDBLOCK
|
|
|
|
|
+
|
|
|
#undef EINPROGRESS
|
|
#undef EINPROGRESS
|
|
|
#define EINPROGRESS WSAEINPROGRESS
|
|
#define EINPROGRESS WSAEINPROGRESS
|
|
|
|
|
+
|
|
|
#undef ENOTSOCK
|
|
#undef ENOTSOCK
|
|
|
#define ENOTSOCK WSAENOTSOCK
|
|
#define ENOTSOCK WSAENOTSOCK
|
|
|
|
|
+
|
|
|
|
|
+#undef EMSGSIZE
|
|
|
|
|
+#define EMSGSIZE WSAEMSGSIZE
|
|
|
|
|
+
|
|
|
#else
|
|
#else
|
|
|
|
|
+
|
|
|
#define blocking(s) fcntl(s, F_SETFL, fcntl(s, F_GETFL) & ~O_NONBLOCK)
|
|
#define blocking(s) fcntl(s, F_SETFL, fcntl(s, F_GETFL) & ~O_NONBLOCK)
|
|
|
#define nonblocking(s) fcntl(s, F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK)
|
|
#define nonblocking(s) fcntl(s, F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK)
|
|
|
|
|
+
|
|
|
typedef int SOCKET;
|
|
typedef int SOCKET;
|
|
|
#define INVALID_SOCKET -1
|
|
#define INVALID_SOCKET -1
|
|
|
#define closesocket close
|
|
#define closesocket close
|
|
|
|
|
+
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
//-----------------------------sockaddr_u----------------------------------------------
|
|
//-----------------------------sockaddr_u----------------------------------------------
|