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