summary refs log tree commit diff stats
path: root/src/common/inet.h
diff options
context:
space:
mode:
authorberkeviktor@aol.com <berkeviktor@aol.com>2011-02-24 04:14:30 +0100
committerberkeviktor@aol.com <berkeviktor@aol.com>2011-02-24 04:14:30 +0100
commit4a6ceffb98a0b785494f680d3776c4bfc4052f9e (patch)
tree850703c1c841ccd99f58d0b06084615aaebe782c /src/common/inet.h
parentf16af8be941b596dedac3bf4e371ee2d21f4b598 (diff)
add xchat r1489
Diffstat (limited to 'src/common/inet.h')
-rw-r--r--src/common/inet.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/common/inet.h b/src/common/inet.h
new file mode 100644
index 00000000..b420c9c6
--- /dev/null
+++ b/src/common/inet.h
@@ -0,0 +1,43 @@
+/* include stuff for internet */
+
+#ifndef WIN32
+
+#ifdef WANTSOCKET
+#include <sys/types.h>
+#include <sys/socket.h>
+#endif
+#ifdef WANTARPA
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+#ifdef WANTDNS
+#include <netdb.h>
+#endif
+#define closesocket close
+#define set_blocking(sok) fcntl(sok, F_SETFL, 0)
+#define set_nonblocking(sok) fcntl(sok, F_SETFL, O_NONBLOCK)
+#define would_block() (errno == EAGAIN || errno == EWOULDBLOCK)
+#define sock_error() (errno)
+
+#else
+
+#ifdef USE_IPV6
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <tpipv6.h>
+#else
+#include <winsock.h>
+#endif
+
+#define set_blocking(sok)	{ \
+									unsigned long zero = 0; \
+									ioctlsocket (sok, FIONBIO, &zero); \
+									}
+#define set_nonblocking(sok)	{ \
+										unsigned long one = 1; \
+										ioctlsocket (sok, FIONBIO, &one); \
+										}
+#define would_block() (WSAGetLastError() == WSAEWOULDBLOCK)
+#define sock_error WSAGetLastError
+
+#endif