author | rubidium |
Thu, 04 Jan 2007 21:21:14 +0000 | |
changeset 5527 | 7a624281971a |
parent 5483 | 8f5640974dbf |
child 5528 | 45a70016d39a |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
5469
7edfc643abbc
(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 |
#ifndef NETWORK_CORE_OS_ABSTRACTION_H |
7edfc643abbc
(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 |
#define NETWORK_CORE_OS_ABSTRACTION_H |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
5 |
|
5469
7edfc643abbc
(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 |
/** |
7edfc643abbc
(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 |
* @file os_abstraction.h Network stuff has many things that needs to be |
7edfc643abbc
(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
|
8 |
* included and/or implemented by default. |
7edfc643abbc
(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
|
9 |
* All those things are in this file. |
7edfc643abbc
(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
|
10 |
*/ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
11 |
|
5469
7edfc643abbc
(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
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
13 |
|
1812
26b041a529e9
(svn r2316) - Fix: [ 1154454 ] Fix BeOS build on Trunk (myob)
Darkvater
parents:
1810
diff
changeset
|
14 |
#ifdef ENABLE_NETWORK |
26b041a529e9
(svn r2316) - Fix: [ 1154454 ] Fix BeOS build on Trunk (myob)
Darkvater
parents:
1810
diff
changeset
|
15 |
|
5469
7edfc643abbc
(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
374f6395847d
(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
374f6395847d
(svn r3008) [ 1247535 ] Native Support for Win64 (compile&run only) (michi_cc)
Darkvater
parents:
2186
diff
changeset
|
20 |
#include <windows.h> |
792
baa707973bd5
(svn r1262) -Fix: [1088996] kill some warnings for MinGW (luzi82)
darkvater
parents:
789
diff
changeset
|
21 |
|
1505
07a27f3cb4f9
(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__)) |
5469
7edfc643abbc
(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 |
|
5469
7edfc643abbc
(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
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
31 |
typedef unsigned long in_addr_t; |
5469
7edfc643abbc
(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
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
33 |
|
5469
7edfc643abbc
(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 */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
35 |
#if defined(UNIX) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
36 |
# define SOCKET int |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
37 |
# define INVALID_SOCKET -1 |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
38 |
# if !defined(__MORPHOS__) && !defined(__AMIGA__) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
39 |
# define ioctlsocket ioctl |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
40 |
# if !defined(BEOS_NET_SERVER) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
41 |
# define closesocket close |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
42 |
# endif |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
43 |
# define GET_LAST_ERROR() (errno) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
44 |
# endif |
5469
7edfc643abbc
(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
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
46 |
# define BSD_COMP |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
47 |
|
5469
7edfc643abbc
(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
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
49 |
# include <unistd.h> |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
50 |
# include <sys/ioctl.h> |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
51 |
# if defined(__BEOS__) && defined(BEOS_NET_SERVER) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
52 |
# include <be/net/socket.h> |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
53 |
# include <be/kernel/OS.h> // snooze() |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
54 |
# include <be/net/netdb.h> |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
55 |
typedef unsigned long in_addr_t; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
56 |
# define INADDR_NONE INADDR_BROADCAST |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
57 |
# else |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
58 |
# include <sys/socket.h> |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
59 |
# include <netinet/in.h> |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
60 |
# include <netinet/tcp.h> |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
61 |
# include <arpa/inet.h> |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
62 |
# include <net/if.h> |
5469
7edfc643abbc
(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
fab86bb654da
(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
521050dcd91e
(svn r2191) -Add: OpenTTD now compiles with dietlibc (Aard)
truelight
parents:
1507
diff
changeset
|
65 |
&& !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) |
5469
7edfc643abbc
(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 |
7edfc643abbc
(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 |
7edfc643abbc
(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
1886a750ccf0
(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 |
1886a750ccf0
(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
1886a750ccf0
(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) |
5469
7edfc643abbc
(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 |
|
5469
7edfc643abbc
(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
3a12c1eadc3f
(svn r1259) -Fix: [Network] Network now compiles with glibc 2.1 (MacBaine)
truelight
parents:
781
diff
changeset
|
80 |
|
1812
26b041a529e9
(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
3a12c1eadc3f
(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
1886a750ccf0
(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
3a12c1eadc3f
(svn r1259) -Fix: [Network] Network now compiles with glibc 2.1 (MacBaine)
truelight
parents:
781
diff
changeset
|
84 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
85 |
# include <errno.h> |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
86 |
# include <sys/time.h> |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
87 |
# include <netdb.h> |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
88 |
#endif // UNIX |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
89 |
|
1429 | 90 |
#ifdef __BEOS__ |
1441
3c9130c733f3
(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 |
||
5469
7edfc643abbc
(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
|
94 |
/* OS/2 stuff */ |
781
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
95 |
#if defined(__OS2__) |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
96 |
# define SOCKET int |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
97 |
# define INVALID_SOCKET -1 |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
98 |
# define ioctlsocket ioctl |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
99 |
# define closesocket close |
810
a1494b19bd2a
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
796
diff
changeset
|
100 |
# define GET_LAST_ERROR() (sock_errno()) |
781
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
101 |
|
5469
7edfc643abbc
(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
|
102 |
/* Includes needed for OS/2 systems */ |
781
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
103 |
# include <types.h> |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
104 |
# include <unistd.h> |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
105 |
# include <sys/ioctl.h> |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
106 |
# include <sys/socket.h> |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
107 |
# include <netinet/in.h> |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
108 |
# include <netinet/tcp.h> |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
109 |
# include <arpa/inet.h> |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
110 |
# include <net/if.h> |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
111 |
# include <errno.h> |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
112 |
# include <sys/time.h> |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
113 |
# include <netdb.h> |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
114 |
# include <nerrno.h> |
810
a1494b19bd2a
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
796
diff
changeset
|
115 |
# define INADDR_NONE 0xffffffff |
781
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
116 |
|
1507
18cb39ddddfd
(svn r2011) - Fix: [ 1162209 ] Fix OS/2 build (orudge) #2
darkvater
parents:
1505
diff
changeset
|
117 |
typedef int socklen_t; |
5305
fab86bb654da
(svn r7461) -Fix: [FS#262] Add support for building with GCC on OS/2 (psmedley)
Darkvater
parents:
4033
diff
changeset
|
118 |
#if !defined(__INNOTEK_LIBC__) |
781
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
119 |
typedef unsigned long in_addr_t; |
5305
fab86bb654da
(svn r7461) -Fix: [FS#262] Add support for building with GCC on OS/2 (psmedley)
Darkvater
parents:
4033
diff
changeset
|
120 |
#endif /* __INNOTEK_LIBC__ */ |
5469
7edfc643abbc
(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
|
121 |
#endif /* OS/2 */ |
781
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
774
diff
changeset
|
122 |
|
5469
7edfc643abbc
(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
|
123 |
/* MorphOS and Amiga stuff */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
124 |
#if defined(__MORPHOS__) || defined(__AMIGA__) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
125 |
# include <exec/types.h> |
5469
7edfc643abbc
(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
|
126 |
# include <proto/exec.h> // required for Open/CloseLibrary() |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
127 |
# if defined(__MORPHOS__) |
5469
7edfc643abbc
(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
|
128 |
# include <sys/filio.h> // FIO* defines |
7edfc643abbc
(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
|
129 |
# include <sys/sockio.h> // SIO* defines |
1343
19445bf5b17e
(svn r1847) Adjustment for MorphOS to unbreak the build there and removal of some now obsolete preprocessor magic
tron
parents:
1342
diff
changeset
|
130 |
# include <netinet/in.h> |
5469
7edfc643abbc
(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
|
131 |
# else /* __AMIGA__ */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
132 |
# include <proto/socket.h> |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
133 |
# endif |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
134 |
|
5469
7edfc643abbc
(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
|
135 |
/* Make the names compatible */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
136 |
# define closesocket(s) CloseSocket(s) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
137 |
# define GET_LAST_ERROR() Errno() |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
138 |
# define ioctlsocket(s,request,status) IoctlSocket((LONG)s,(ULONG)request,(char*)status) |
770
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
139 |
# define ioctl ioctlsocket |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
140 |
|
770
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
141 |
typedef unsigned int in_addr_t; |
1343
19445bf5b17e
(svn r1847) Adjustment for MorphOS to unbreak the build there and removal of some now obsolete preprocessor magic
tron
parents:
1342
diff
changeset
|
142 |
typedef long socklen_t; |
770
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
143 |
extern struct Library *SocketBase; |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
144 |
|
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
145 |
# ifdef __AMIGA__ |
5469
7edfc643abbc
(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 |
/* for usleep() implementation */ |
770
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
147 |
extern struct Device *TimerBase; |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
148 |
extern struct MsgPort *TimerPort; |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
149 |
extern struct timerequest *TimerRequest; |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
706
diff
changeset
|
150 |
# endif |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
151 |
#endif // __MORPHOS__ || __AMIGA__ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
152 |
|
1332
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
153 |
static inline bool SetNonBlocking(int d) |
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
154 |
{ |
5469
7edfc643abbc
(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 |
#ifdef WIN32 |
1466 | 156 |
u_long nonblocking = 1; |
5469
7edfc643abbc
(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 |
1332
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
158 |
int nonblocking = 1; |
5469
7edfc643abbc
(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
|
159 |
#endif |
7edfc643abbc
(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
|
160 |
#if defined(__BEOS__) && defined(BEOS_NET_SERVER) |
1332
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
161 |
return setsockopt(d, SOL_SOCKET, SO_NONBLOCK, &nonblocking, sizeof(nonblocking)) == 0; |
5469
7edfc643abbc
(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
|
162 |
#else |
1332
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
163 |
return ioctlsocket(d, FIONBIO, &nonblocking) == 0; |
5469
7edfc643abbc
(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
|
164 |
#endif |
1332
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
165 |
} |
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
166 |
|
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
167 |
static inline bool SetNoDelay(int d) |
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
168 |
{ |
5469
7edfc643abbc
(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
|
169 |
/* XXX should this be done at all? */ |
7edfc643abbc
(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
|
170 |
#if !defined(BEOS_NET_SERVER) // not implemented on BeOS net_server |
1332
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
171 |
int b = 1; |
5469
7edfc643abbc
(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 |
/* The (const char*) cast is needed for windows */ |
1332
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
173 |
return setsockopt(d, IPPROTO_TCP, TCP_NODELAY, (const char*)&b, sizeof(b)) == 0; |
5469
7edfc643abbc
(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
|
174 |
#else |
1332
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
175 |
return true; |
5469
7edfc643abbc
(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
|
176 |
#endif |
1332
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
177 |
} |
0cae74c93b5d
(svn r1836) Clean up some strange constructs concerning socket options
tron
parents:
1051
diff
changeset
|
178 |
|
5483
8f5640974dbf
(svn r7767) -Fix r7751: [OSX] nameclash in includes. ALIGN was defined in both a library and macros.h
bjarni
parents:
5475
diff
changeset
|
179 |
#ifdef __APPLE__ |
8f5640974dbf
(svn r7767) -Fix r7751: [OSX] nameclash in includes. ALIGN was defined in both a library and macros.h
bjarni
parents:
5475
diff
changeset
|
180 |
/* Looks like sys/socket.h uses a name we got in macros.h */ |
8f5640974dbf
(svn r7767) -Fix r7751: [OSX] nameclash in includes. ALIGN was defined in both a library and macros.h
bjarni
parents:
5475
diff
changeset
|
181 |
#undef ALIGN |
8f5640974dbf
(svn r7767) -Fix r7751: [OSX] nameclash in includes. ALIGN was defined in both a library and macros.h
bjarni
parents:
5475
diff
changeset
|
182 |
#endif |
8f5640974dbf
(svn r7767) -Fix r7751: [OSX] nameclash in includes. ALIGN was defined in both a library and macros.h
bjarni
parents:
5475
diff
changeset
|
183 |
|
1812
26b041a529e9
(svn r2316) - Fix: [ 1154454 ] Fix BeOS build on Trunk (myob)
Darkvater
parents:
1810
diff
changeset
|
184 |
#endif /* ENABLE_NETWORK */ |
26b041a529e9
(svn r2316) - Fix: [ 1154454 ] Fix BeOS build on Trunk (myob)
Darkvater
parents:
1810
diff
changeset
|
185 |
|
5469
7edfc643abbc
(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
|
186 |
#endif /* NETWORK_CORE_OS_ABSTRACTION_H */ |