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 license.txt 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 #include <sys/types.h>
19 #include <sys/socket.h>
20 #include <sys/fcntl.h>
21 #include <arpa/inet.h>
27 #include <netinet/in.h>
32 #define MSG_NOSIGNAL 0
33 #define MSG_DONTWAIT 0
34 typedef int socklen_t;
37 #define WSAGetLastError() errno
38 #define WSAEINVAL EINVAL
39 #define WSAEALREADY EALREADY
40 #define WSAEWOULDBLOCK EWOULDBLOCK
41 #define WSAEMSGSIZE EMSGSIZE
42 #define WSAEINTR EINTR
43 #define WSAEINPROGRESS EINPROGRESS
44 #define WSAEADDRINUSE EADDRINUSE
45 #define WSAENOTSOCK EBADF
46 #define INVALID_SOCKET (SOCKET)(~0)
47 #define SOCKET_ERROR -1
50 inline int myclosesocket(SOCKET& hSocket)
52 if (hSocket == INVALID_SOCKET)
55 int ret = closesocket(hSocket);
57 int ret = close(hSocket);
59 hSocket = INVALID_SOCKET;
62 #define closesocket(s) myclosesocket(s)