Feathercoin  0.5.0
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
compat.h
Go to the documentation of this file.
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
7 
8 #ifdef WIN32
9 #define _WIN32_WINNT 0x0501
10 #define WIN32_LEAN_AND_MEAN 1
11 #ifndef NOMINMAX
12 #define NOMINMAX
13 #endif
14 #define FD_SETSIZE 1024 // max number of fds in fd_set
15 #include <winsock2.h>
16 #include <mswsock.h>
17 #include <ws2tcpip.h>
18 #else
19 #include <sys/types.h>
20 #include <sys/socket.h>
21 #include <sys/fcntl.h>
22 #include <arpa/inet.h>
23 #include <netdb.h>
24 #include <net/if.h>
25 #include <netinet/in.h>
26 #include <ifaddrs.h>
27 #endif
28 
29 typedef u_int SOCKET;
30 #ifdef WIN32
31 #define MSG_NOSIGNAL 0
32 #define MSG_DONTWAIT 0
33 typedef int socklen_t;
34 #else
35 #include "errno.h"
36 #define WSAGetLastError() errno
37 #define WSAEINVAL EINVAL
38 #define WSAEALREADY EALREADY
39 #define WSAEWOULDBLOCK EWOULDBLOCK
40 #define WSAEMSGSIZE EMSGSIZE
41 #define WSAEINTR EINTR
42 #define WSAEINPROGRESS EINPROGRESS
43 #define WSAEADDRINUSE EADDRINUSE
44 #define WSAENOTSOCK EBADF
45 #define INVALID_SOCKET (SOCKET)(~0)
46 #define SOCKET_ERROR -1
47 #endif
48 
49 inline int myclosesocket(SOCKET& hSocket)
50 {
51  if (hSocket == INVALID_SOCKET)
52  return WSAENOTSOCK;
53 #ifdef WIN32
54  int ret = closesocket(hSocket);
55 #else
56  int ret = close(hSocket);
57 #endif
58  hSocket = INVALID_SOCKET;
59  return ret;
60 }
61 #define closesocket(s) myclosesocket(s)
62 
63 
64 #endif
#define closesocket(s)
Definition: compat.h:61
u_int SOCKET
Definition: compat.h:29
#define INVALID_SOCKET
Definition: compat.h:45
int myclosesocket(SOCKET &hSocket)
Definition: compat.h:49
#define WSAENOTSOCK
Definition: compat.h:44