Commit | Line | Data |
---|---|---|
23e7e3ae JVH |
1 | /** |
2 | * Copyright (C) 2011-2012 Juho Vähä-Herttua | |
3 | * | |
4 | * This library is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU Lesser General Public | |
6 | * License as published by the Free Software Foundation; either | |
7 | * version 2.1 of the License, or (at your option) any later version. | |
8 | * | |
9 | * This library is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | * Lesser General Public License for more details. | |
13 | */ | |
14 | ||
2340bcd3 JVH |
15 | #ifndef SOCKETS_H |
16 | #define SOCKETS_H | |
17 | ||
18 | #if defined(WIN32) | |
19 | typedef int socklen_t; | |
20 | ||
21 | #ifndef SHUT_RD | |
22 | # define SHUT_RD SD_RECEIVE | |
23 | #endif | |
24 | #ifndef SHUT_WR | |
25 | # define SHUT_WR SD_SEND | |
26 | #endif | |
27 | #ifndef SHUT_RDWR | |
28 | # define SHUT_RDWR SD_BOTH | |
29 | #endif | |
30 | ||
31 | #define SOCKET_GET_ERROR() WSAGetLastError() | |
32 | #define SOCKET_SET_ERROR(value) WSASetLastError(value) | |
33 | #define SOCKET_ERRORNAME(name) WSA##name | |
34 | ||
35 | #define WSAEAGAIN WSAEWOULDBLOCK | |
36 | #define WSAENOMEM WSA_NOT_ENOUGH_MEMORY | |
37 | ||
38 | #else | |
39 | ||
40 | #define closesocket close | |
41 | #define ioctlsocket ioctl | |
42 | ||
43 | #define SOCKET_GET_ERROR() (errno) | |
44 | #define SOCKET_SET_ERROR(value) (errno = (value)) | |
45 | #define SOCKET_ERRORNAME(name) name | |
46 | ||
47 | #endif | |
48 | ||
49 | #endif |