author | KUDr |
Sat, 21 Apr 2007 08:23:57 +0000 | |
branch | cpp_gui |
changeset 6308 | 646711c5feaa |
parent 6268 | 4b5241e5dd10 |
child 6871 | 5a9dc001e1ad |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
3 |
/** |
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
4 |
* @file os_abstraction.h Network stuff has many things that needs to be |
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
5 |
* included and/or implemented by default. |
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
6 |
* All those things are in this file. |
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
7 |
*/ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
8 |
|
6268
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
6227
diff
changeset
|
9 |
#ifndef NETWORK_CORE_OS_ABSTRACTION_H |
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
6227
diff
changeset
|
10 |
#define NETWORK_CORE_OS_ABSTRACTION_H |
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
6227
diff
changeset
|
11 |
|
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
12 |
/* Include standard stuff per OS */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
13 |
|
1812
5b4d1af6b904
(svn r2316) - Fix: [ 1154454 ] Fix BeOS build on Trunk (myob)
Darkvater
parents:
1810
diff
changeset
|
14 |
#ifdef ENABLE_NETWORK |
5b4d1af6b904
(svn r2316) - Fix: [ 1154454 ] Fix BeOS build on Trunk (myob)
Darkvater
parents:
1810
diff
changeset
|
15 |
|
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
16 |
/* Windows stuff */ |
2482
dffcca243dbc
(svn r3008) [ 1247535 ] Native Support for Win64 (compile&run only) (michi_cc)
Darkvater
parents:
2186
diff
changeset
|
17 |
#if defined(WIN32) || defined(WIN64) |
796 | 18 |
#include <winsock2.h> |
19 |
#include <ws2tcpip.h> |
|
2482
dffcca243dbc
(svn r3008) [ 1247535 ] Native Support for Win64 (compile&run only) (michi_cc)
Darkvater
parents:
2186
diff
changeset
|
20 |
#include <windows.h> |
792
d8a4164fdb14
(svn r1262) -Fix: [1088996] kill some warnings for MinGW (luzi82)
darkvater
parents:
789
diff
changeset
|
21 |
|
1505
f09ef05540d0
(svn r2009) - VS.NET/VS6 removed all builds except for Release and Debug. Also add additional dependencies to the project file instead of in the header file itself.
darkvater
parents:
1466
diff
changeset
|
22 |
#if !(defined(__MINGW32__) || defined(__CYGWIN__)) |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
23 |
/* Windows has some different names for some types */ |
796 | 24 |
typedef SSIZE_T ssize_t; |
1342 | 25 |
typedef int socklen_t; |
796 | 26 |
#endif |
27 |
||
28 |
#define GET_LAST_ERROR() WSAGetLastError() |
|
29 |
#define EWOULDBLOCK WSAEWOULDBLOCK |
|
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
30 |
/* Windows has some different names for some types */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
31 |
typedef unsigned long in_addr_t; |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
32 |
#endif /* WIN32 */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
33 |
|
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
34 |
/* UNIX stuff */ |
5791
f53ba2af16a2
(svn r7882) -Fix: OS2 is defined as UNIX too, but not for networking
truelight
parents:
5779
diff
changeset
|
35 |
#if defined(UNIX) && !defined(__OS2__) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
36 |
# define SOCKET int |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
37 |
# define INVALID_SOCKET -1 |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
38 |
# if !defined(__MORPHOS__) && !defined(__AMIGA__) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
39 |
# define ioctlsocket ioctl |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
40 |
# if !defined(BEOS_NET_SERVER) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
41 |
# define closesocket close |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
42 |
# endif |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
43 |
# define GET_LAST_ERROR() (errno) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
44 |
# endif |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
45 |
/* Need this for FIONREAD on solaris */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
46 |
# define BSD_COMP |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
47 |
|
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
48 |
/* Includes needed for UNIX-like systems */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
49 |
# include <unistd.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
50 |
# include <sys/ioctl.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
51 |
# if defined(__BEOS__) && defined(BEOS_NET_SERVER) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
52 |
# include <be/net/socket.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
53 |
# include <be/kernel/OS.h> // snooze() |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
54 |
# include <be/net/netdb.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
55 |
typedef unsigned long in_addr_t; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
56 |
# define INADDR_NONE INADDR_BROADCAST |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
57 |
# else |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
58 |
# include <sys/socket.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
59 |
# include <netinet/in.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
60 |
# include <netinet/tcp.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
61 |
# include <arpa/inet.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
62 |
# include <net/if.h> |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
63 |
/* According to glibc/NEWS, <ifaddrs.h> appeared in glibc-2.3. */ |
5305
e07957fe871e
(svn r7461) -Fix: [FS#262] Add support for building with GCC on OS/2 (psmedley)
Darkvater
parents:
4033
diff
changeset
|
64 |
# if !defined(__sgi__) && !defined(SUNOS) && !defined(__MORPHOS__) && !defined(__BEOS__) && !defined(__INNOTEK_LIBC__) \ |
1687
2265b1f3de0b
(svn r2191) -Add: OpenTTD now compiles with dietlibc (Aard)
truelight
parents:
1507
diff
changeset
|
65 |
&& !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
66 |
/* If for any reason ifaddrs.h does not exist on your system, comment out |
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
67 |
* the following two lines and an alternative way will be used to fetch |
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
68 |
* the list of IPs from the system. */ |
706 | 69 |
# include <ifaddrs.h> |
70 |
# define HAVE_GETIFADDRS |
|
1412
189b1b7f98ed
(svn r1916) Fix compilation on the glibc-2.2 systems. Part of the inspiration comes from patch 1149710 by Mr. Nobody. Also fixes the comment describing what to do if one's system doesn't have ifaddrs.h.
pasky
parents:
1343
diff
changeset
|
71 |
# endif |
189b1b7f98ed
(svn r1916) Fix compilation on the glibc-2.2 systems. Part of the inspiration comes from patch 1149710 by Mr. Nobody. Also fixes the comment describing what to do if one's system doesn't have ifaddrs.h.
pasky
parents:
1343
diff
changeset
|
72 |
# if defined(SUNOS) || defined(__MORPHOS__) || defined(__BEOS__) |
706 | 73 |
# define INADDR_NONE 0xffffffff |
1412
189b1b7f98ed
(svn r1916) Fix compilation on the glibc-2.2 systems. Part of the inspiration comes from patch 1149710 by Mr. Nobody. Also fixes the comment describing what to do if one's system doesn't have ifaddrs.h.
pasky
parents:
1343
diff
changeset
|
74 |
# endif |
1051 | 75 |
# if defined(__BEOS__) && !defined(BEOS_NET_SERVER) |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
76 |
/* needed on Zeta */ |
1051 | 77 |
# include <sys/sockio.h> |
78 |
# endif |
|
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
79 |
# endif /* BEOS_NET_SERVER */ |
789
85be14beeb57
(svn r1259) -Fix: [Network] Network now compiles with glibc 2.1 (MacBaine)
truelight
parents:
781
diff
changeset
|
80 |
|
1812
5b4d1af6b904
(svn r2316) - Fix: [ 1154454 ] Fix BeOS build on Trunk (myob)
Darkvater
parents:
1810
diff
changeset
|
81 |
# if !defined(__BEOS__) && defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 1) |
789
85be14beeb57
(svn r1259) -Fix: [Network] Network now compiles with glibc 2.1 (MacBaine)
truelight
parents:
781
diff
changeset
|
82 |
typedef uint32_t in_addr_t; |
1412
189b1b7f98ed
(svn r1916) Fix compilation on the glibc-2.2 systems. Part of the inspiration comes from patch 1149710 by Mr. Nobody. Also fixes the comment describing what to do if one's system doesn't have ifaddrs.h.
pasky
parents:
1343
diff
changeset
|
83 |
# endif |
789
85be14beeb57
(svn r1259) -Fix: [Network] Network now compiles with glibc 2.1 (MacBaine)
truelight
parents:
781
diff
changeset
|
84 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
85 |
# include <errno.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
86 |
# include <sys/time.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
87 |
# include <netdb.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
88 |
#endif // UNIX |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
89 |
|
1429 | 90 |
#ifdef __BEOS__ |
1441
43c2b48559fa
(svn r1945) - CodeChange: re-commit of rev 1835: "Reduce the visibility of network_core.h (Tron)".
darkvater
parents:
1429
diff
changeset
|
91 |
typedef int socklen_t; |
1429 | 92 |
#endif |
93 |
||
6227
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
94 |
#if defined(PSP) |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
95 |
# include <sys/socket.h> |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
96 |
# include <netinet/in.h> |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
97 |
# include <arpa/inet.h> |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
98 |
# include <pspnet.h> |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
99 |
# include <pspnet_inet.h> |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
100 |
# include <pspnet_apctl.h> |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
101 |
# include <pspnet_resolver.h> |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
102 |
# include <errno.h> |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
103 |
# include <unistd.h> |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
104 |
# include <sys/select.h> |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
105 |
# include <sys/time.h> |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
106 |
# include <sys/fd_set.h> |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
107 |
|
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
108 |
# define TCP_NODELAY 1 |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
109 |
# define SO_NONBLOCK 0x1009 |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
110 |
# define SOCKET int |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
111 |
# define INVALID_SOCKET -1 |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
112 |
# define INADDR_NONE 0xffffffff |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
113 |
# define closesocket close |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
114 |
# define GET_LAST_ERROR() sceNetInetGetErrno() |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
115 |
#endif /* PSP */ |
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
116 |
|
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
117 |
/* OS/2 stuff */ |
781
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
118 |
#if defined(__OS2__) |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
119 |
# define SOCKET int |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
120 |
# define INVALID_SOCKET -1 |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
121 |
# define ioctlsocket ioctl |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
122 |
# define closesocket close |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
796
diff
changeset
|
123 |
# define GET_LAST_ERROR() (sock_errno()) |
781
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
124 |
|
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
125 |
/* Includes needed for OS/2 systems */ |
781
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
126 |
# include <types.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
127 |
# include <unistd.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
128 |
# include <sys/ioctl.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
129 |
# include <sys/socket.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
130 |
# include <netinet/in.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
131 |
# include <netinet/tcp.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
132 |
# include <arpa/inet.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
133 |
# include <net/if.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
134 |
# include <errno.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
135 |
# include <sys/time.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
136 |
# include <netdb.h> |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
137 |
# include <nerrno.h> |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
796
diff
changeset
|
138 |
# define INADDR_NONE 0xffffffff |
781
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
139 |
|
1507
2d09b13f049f
(svn r2011) - Fix: [ 1162209 ] Fix OS/2 build (orudge) #2
darkvater
parents:
1505
diff
changeset
|
140 |
typedef int socklen_t; |
5305
e07957fe871e
(svn r7461) -Fix: [FS#262] Add support for building with GCC on OS/2 (psmedley)
Darkvater
parents:
4033
diff
changeset
|
141 |
#if !defined(__INNOTEK_LIBC__) |
781
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
142 |
typedef unsigned long in_addr_t; |
5305
e07957fe871e
(svn r7461) -Fix: [FS#262] Add support for building with GCC on OS/2 (psmedley)
Darkvater
parents:
4033
diff
changeset
|
143 |
#endif /* __INNOTEK_LIBC__ */ |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
144 |
#endif /* OS/2 */ |
781
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
145 |
|
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
146 |
/* MorphOS and Amiga stuff */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
147 |
#if defined(__MORPHOS__) || defined(__AMIGA__) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
148 |
# include <exec/types.h> |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
149 |
# include <proto/exec.h> // required for Open/CloseLibrary() |
6092
cb42399ba6e5
(svn r8411) [MorphOS] -Fix: tons of unneeded warnings in networking code, because MorphOS wants UBYTE arrays and we use char arrays. Solution is a bit hackish.
truelight
parents:
5791
diff
changeset
|
150 |
/* MorphOS defines his network functions with UBYTE arrays while we |
cb42399ba6e5
(svn r8411) [MorphOS] -Fix: tons of unneeded warnings in networking code, because MorphOS wants UBYTE arrays and we use char arrays. Solution is a bit hackish.
truelight
parents:
5791
diff
changeset
|
151 |
* use char arrays. This gives tons of unneeded warnings */ |
cb42399ba6e5
(svn r8411) [MorphOS] -Fix: tons of unneeded warnings in networking code, because MorphOS wants UBYTE arrays and we use char arrays. Solution is a bit hackish.
truelight
parents:
5791
diff
changeset
|
152 |
# define UBYTE char |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
153 |
# if defined(__MORPHOS__) |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
154 |
# include <sys/filio.h> // FIO* defines |
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
155 |
# include <sys/sockio.h> // SIO* defines |
1343
481847e32573
(svn r1847) Adjustment for MorphOS to unbreak the build there and removal of some now obsolete preprocessor magic
tron
parents:
1342
diff
changeset
|
156 |
# include <netinet/in.h> |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
157 |
# else /* __AMIGA__ */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
158 |
# include <proto/socket.h> |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
159 |
# endif |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
160 |
|
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
161 |
/* Make the names compatible */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
162 |
# define closesocket(s) CloseSocket(s) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
163 |
# define GET_LAST_ERROR() Errno() |
6308 | 164 |
# define ioctlsocket(s, request, status) IoctlSocket((LONG)s, (ULONG)request, (char*)status) |
770
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
165 |
# define ioctl ioctlsocket |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
166 |
|
770
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
167 |
typedef unsigned int in_addr_t; |
1343
481847e32573
(svn r1847) Adjustment for MorphOS to unbreak the build there and removal of some now obsolete preprocessor magic
tron
parents:
1342
diff
changeset
|
168 |
typedef long socklen_t; |
770
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
169 |
extern struct Library *SocketBase; |
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
170 |
|
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
171 |
# ifdef __AMIGA__ |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
172 |
/* for usleep() implementation */ |
770
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
173 |
extern struct Device *TimerBase; |
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
174 |
extern struct MsgPort *TimerPort; |
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
175 |
extern struct timerequest *TimerRequest; |
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
176 |
# endif |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
177 |
#endif // __MORPHOS__ || __AMIGA__ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
178 |
|
6226
993f5aa4c6cb
(svn r8673) -Codechange: use SetNonBlocking instead of implementing yet another version.
rubidium
parents:
6092
diff
changeset
|
179 |
static inline bool SetNonBlocking(SOCKET d) |
1332
86c9ebbcda31
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
180 |
{ |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
181 |
#ifdef WIN32 |
1466 | 182 |
u_long nonblocking = 1; |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
183 |
#else |
1332
86c9ebbcda31
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
184 |
int nonblocking = 1; |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
185 |
#endif |
6227
ab74f5faf662
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents:
6226
diff
changeset
|
186 |
#if (defined(__BEOS__) && defined(BEOS_NET_SERVER)) || defined(PSP) |
1332
86c9ebbcda31
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
187 |
return setsockopt(d, SOL_SOCKET, SO_NONBLOCK, &nonblocking, sizeof(nonblocking)) == 0; |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
188 |
#else |
1332
86c9ebbcda31
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
189 |
return ioctlsocket(d, FIONBIO, &nonblocking) == 0; |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
190 |
#endif |
1332
86c9ebbcda31
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
191 |
} |
86c9ebbcda31
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
192 |
|
6226
993f5aa4c6cb
(svn r8673) -Codechange: use SetNonBlocking instead of implementing yet another version.
rubidium
parents:
6092
diff
changeset
|
193 |
static inline bool SetNoDelay(SOCKET d) |
1332
86c9ebbcda31
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
194 |
{ |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
195 |
/* XXX should this be done at all? */ |
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
196 |
#if !defined(BEOS_NET_SERVER) // not implemented on BeOS net_server |
1332
86c9ebbcda31
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
197 |
int b = 1; |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
198 |
/* The (const char*) cast is needed for windows */ |
1332
86c9ebbcda31
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
199 |
return setsockopt(d, IPPROTO_TCP, TCP_NODELAY, (const char*)&b, sizeof(b)) == 0; |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
200 |
#else |
1332
86c9ebbcda31
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
201 |
return true; |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
202 |
#endif |
1332
86c9ebbcda31
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
203 |
} |
86c9ebbcda31
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
204 |
|
5734
3f0df7edf4f1
(svn r7767) -Fix r7751: [OSX] nameclash in includes. ALIGN was defined in both a library and macros.h
bjarni
parents:
5726
diff
changeset
|
205 |
#ifdef __APPLE__ |
3f0df7edf4f1
(svn r7767) -Fix r7751: [OSX] nameclash in includes. ALIGN was defined in both a library and macros.h
bjarni
parents:
5726
diff
changeset
|
206 |
/* Looks like sys/socket.h uses a name we got in macros.h */ |
3f0df7edf4f1
(svn r7767) -Fix r7751: [OSX] nameclash in includes. ALIGN was defined in both a library and macros.h
bjarni
parents:
5726
diff
changeset
|
207 |
#undef ALIGN |
3f0df7edf4f1
(svn r7767) -Fix r7751: [OSX] nameclash in includes. ALIGN was defined in both a library and macros.h
bjarni
parents:
5726
diff
changeset
|
208 |
#endif |
3f0df7edf4f1
(svn r7767) -Fix r7751: [OSX] nameclash in includes. ALIGN was defined in both a library and macros.h
bjarni
parents:
5726
diff
changeset
|
209 |
|
1812
5b4d1af6b904
(svn r2316) - Fix: [ 1154454 ] Fix BeOS build on Trunk (myob)
Darkvater
parents:
1810
diff
changeset
|
210 |
#endif /* ENABLE_NETWORK */ |
5b4d1af6b904
(svn r2316) - Fix: [ 1154454 ] Fix BeOS build on Trunk (myob)
Darkvater
parents:
1810
diff
changeset
|
211 |
|
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5305
diff
changeset
|
212 |
#endif /* NETWORK_CORE_OS_ABSTRACTION_H */ |