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
18 #define FD_SETSIZE 1024 // max number of fds in fd_set
24 #include <sys/types.h>
25 #include <sys/socket.h>
29 #include <sys/fcntl.h>
31 #include <arpa/inet.h>
34 #include <netinet/in.h>
41 #define MSG_NOSIGNAL 0
42 #define MSG_DONTWAIT 0
43 typedef int socklen_t;
46 #define WSAGetLastError() errno
47 #define WSAEINVAL EINVAL
48 #define WSAEALREADY EALREADY
49 #define WSAEWOULDBLOCK EWOULDBLOCK
50 #define WSAEMSGSIZE EMSGSIZE
51 #define WSAEINTR EINTR
52 #define WSAEINPROGRESS EINPROGRESS
53 #define WSAEADDRINUSE EADDRINUSE
54 #define WSAENOTSOCK EBADF
55 #define INVALID_SOCKET (SOCKET)(~0)
56 #define SOCKET_ERROR -1
59 inline int myclosesocket(SOCKET& hSocket)
61 if (hSocket == INVALID_SOCKET)
64 int ret = closesocket(hSocket);
66 int ret = close(hSocket);
68 hSocket = INVALID_SOCKET;
71 #define closesocket(s) myclosesocket(s)