|
1 /* |
|
2 SDL_net: An example cross-platform network library for use with SDL |
|
3 Copyright (C) 1997-2004 Sam Lantinga |
|
4 |
|
5 This library is free software; you can redistribute it and/or |
|
6 modify it under the terms of the GNU Library General Public |
|
7 License as published by the Free Software Foundation; either |
|
8 version 2 of the License, or (at your option) any later version. |
|
9 |
|
10 This library is distributed in the hope that it will be useful, |
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 Library General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU Library General Public |
|
16 License along with this library; if not, write to the Free |
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 |
|
19 Sam Lantinga |
|
20 slouken@libsdl.org |
|
21 */ |
|
22 |
|
23 /* $Id: SDLnetsys.h 1720 2005-11-23 07:57:10Z icculus $ */ |
|
24 |
|
25 /* Include normal system headers */ |
|
26 #include <stdio.h> |
|
27 #include <stdlib.h> |
|
28 #include <string.h> |
|
29 #include <errno.h> |
|
30 |
|
31 #ifdef macintosh |
|
32 #ifndef USE_GUSI_SOCKETS |
|
33 #define MACOS_OPENTRANSPORT |
|
34 //#error Open Transport driver is broken |
|
35 #endif |
|
36 #endif /* macintosh */ |
|
37 |
|
38 /* Include system network headers */ |
|
39 #ifdef MACOS_OPENTRANSPORT |
|
40 #include <OpenTransport.h> |
|
41 #include <OpenTptInternet.h> |
|
42 #else |
|
43 #if defined(__WIN32__) || defined(WIN32) |
|
44 #define __USE_W32_SOCKETS |
|
45 #include <windows.h> |
|
46 #else /* UNIX */ |
|
47 #ifdef __OS2__ |
|
48 #include <types.h> |
|
49 #include <sys/ioctl.h> |
|
50 #endif |
|
51 #include <sys/time.h> |
|
52 #include <unistd.h> |
|
53 #include <fcntl.h> |
|
54 #include <netinet/in.h> |
|
55 #ifndef __BEOS__ |
|
56 #include <arpa/inet.h> |
|
57 #endif |
|
58 #ifdef linux /* FIXME: what other platforms have this? */ |
|
59 #include <netinet/tcp.h> |
|
60 #endif |
|
61 #include <netdb.h> |
|
62 #include <sys/socket.h> |
|
63 #endif /* WIN32 */ |
|
64 #endif /* Open Transport */ |
|
65 |
|
66 /* System-dependent definitions */ |
|
67 #ifdef MACOS_OPENTRANSPORT |
|
68 //#define closesocket OTCloseProvider |
|
69 #define closesocket OTSndOrderlyDisconnect |
|
70 #define SOCKET EndpointRef |
|
71 #define INVALID_SOCKET kOTInvalidEndpointRef |
|
72 #else |
|
73 #ifndef __USE_W32_SOCKETS |
|
74 #ifdef __OS2__ |
|
75 #define closesocket soclose |
|
76 #else /* !__OS2__ */ |
|
77 #define closesocket close |
|
78 #endif /* __OS2__ */ |
|
79 #define SOCKET int |
|
80 #define INVALID_SOCKET -1 |
|
81 #define SOCKET_ERROR -1 |
|
82 #endif /* __USE_W32_SOCKETS */ |
|
83 #endif /* Open Transport */ |
|
84 |