1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2012 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 #ifndef _BITCOIN_COMPAT_H
6 #define _BITCOIN_COMPAT_H 1
9 #define _WIN32_WINNT 0x0501
10 #define WIN32_LEAN_AND_MEAN 1
15 #define FD_SETSIZE 1024 // max number of fds in fd_set
21 #include <sys/types.h>
22 #include <sys/socket.h>
23 #include <sys/fcntl.h>
24 #include <arpa/inet.h>
27 #include <netinet/in.h>
34 #define MSG_NOSIGNAL 0
35 #define MSG_DONTWAIT 0
36 typedef int socklen_t;
39 #define WSAGetLastError() errno
40 #define WSAEINVAL EINVAL
41 #define WSAEALREADY EALREADY
42 #define WSAEWOULDBLOCK EWOULDBLOCK
43 #define WSAEMSGSIZE EMSGSIZE
44 #define WSAEINTR EINTR
45 #define WSAEINPROGRESS EINPROGRESS
46 #define WSAEADDRINUSE EADDRINUSE
47 #define WSAENOTSOCK EBADF
48 #define INVALID_SOCKET (SOCKET)(~0)
49 #define SOCKET_ERROR -1
52 inline int myclosesocket(SOCKET& hSocket)
54 if (hSocket == INVALID_SOCKET)
57 int ret = closesocket(hSocket);
59 int ret = close(hSocket);
61 hSocket = INVALID_SOCKET;
64 #define closesocket(s) myclosesocket(s)