diff options
author | tron <tron@openttd.org> | 2005-02-07 09:56:16 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-02-07 09:56:16 +0000 |
commit | 552d84884f8f0d4424297f7df773f70a65ff4437 (patch) | |
tree | 1b3f90adfce92f9f4195f19e3c115416943a615b /network_core.h | |
parent | 7c38b7bc014fdae1cd50b1f3a8f5b798a53a15d3 (diff) | |
download | openttd-552d84884f8f0d4424297f7df773f70a65ff4437.tar.xz |
(svn r1836) Clean up some strange constructs concerning socket options
Diffstat (limited to 'network_core.h')
-rw-r--r-- | network_core.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/network_core.h b/network_core.h index c6a2789b6..6627576cf 100644 --- a/network_core.h +++ b/network_core.h @@ -140,4 +140,26 @@ typedef unsigned long in_addr_t; # endif #endif // __MORPHOS__ || __AMIGA__ +static inline bool SetNonBlocking(int d) +{ + int nonblocking = 1; + #if defined(__BEOS__) && defined(BEOS_NET_SERVER) + return setsockopt(d, SOL_SOCKET, SO_NONBLOCK, &nonblocking, sizeof(nonblocking)) == 0; + #else + return ioctlsocket(d, FIONBIO, &nonblocking) == 0; + #endif +} + +static inline bool SetNoDelay(int d) +{ + // XXX should this be done at all? + #if !defined(BEOS_NET_SERVER) // not implemented on BeOS net_server + int b = 1; + // The (const char*) cast is needed for windows + return setsockopt(d, IPPROTO_TCP, TCP_NODELAY, (const char*)&b, sizeof(b)) == 0; + #else + return true; + #endif +} + #endif // NETWORK_CORE_H |