zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDLnetsys.h
Go to the documentation of this file.
1 /*
2  SDL_net: An example cross-platform network library for use with SDL
3  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 /* $Id$ */
23 
24 /* Include normal system headers */
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <time.h>
29 
30 #ifndef _WIN32_WCE
31 #include <errno.h>
32 #endif
33 
34 /* Include system network headers */
35 #if defined(__WIN32__) || defined(WIN32)
36 #define __USE_W32_SOCKETS
37 #ifdef _WIN64
38 #include <winsock2.h>
39 #include <ws2tcpip.h>
40 #else
41 #include <winsock.h>
42 /* NOTE: windows socklen_t is signed
43  * and is defined only for winsock2. */
44 typedef int socklen_t;
45 #endif /* W64 */
46 #include <iphlpapi.h>
47 #else /* UNIX */
48 #include <sys/types.h>
49 #ifdef __FreeBSD__
50 #include <sys/socket.h>
51 #endif
52 #include <sys/ioctl.h>
53 #include <sys/time.h>
54 #include <unistd.h>
55 #include <fcntl.h>
56 #include <netinet/in.h>
57 #ifndef __BEOS__
58 #include <arpa/inet.h>
59 #endif
60 #include <netinet/tcp.h>
61 #include <sys/socket.h>
62 #include <net/if.h>
63 #include <netdb.h>
64 #endif /* WIN32 */
65 
66 /* FIXME: What platforms need this? */
67 #if 0
68 typedef Uint32 socklen_t;
69 #endif
70 
71 /* System-dependent definitions */
72 #ifndef __USE_W32_SOCKETS
73 #ifdef __OS2__
74 #define closesocket soclose
75 #else /* !__OS2__ */
76 #define closesocket close
77 #endif /* __OS2__ */
78 #define SOCKET int
79 #define INVALID_SOCKET -1
80 #define SOCKET_ERROR -1
81 #endif /* __USE_W32_SOCKETS */
82 
83 #ifdef __USE_W32_SOCKETS
84 #define SDLNet_GetLastError WSAGetLastError
85 #define SDLNet_SetLastError WSASetLastError
86 #ifndef EINTR
87 #define EINTR WSAEINTR
88 #endif
89 #else
90 int SDLNet_GetLastError(void);
91 void SDLNet_SetLastError(int err);
92 #endif
93 
int SDLNet_GetLastError(void)
Definition: SDLnet.c:51
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:145
void SDLNet_SetLastError(int err)
Definition: SDLnet.c:56