41 #ifndef _networkplatformsocket_h_cpp
42 #define _networkplatformsocket_h_cpp
44 #include "Network/platformincludes.h.cpp"
46 #include "Network/socketdescription.h"
47 #include "Network/systemaddress.h"
53 #if defined(MEZZ_WINDOWS)
59 typedef SOCKET SocketHandleImplementation;
60 #elif defined(MEZZ_MACOSX) || defined(MEZZ_LINUX)
63 typedef socklen_t AddrLen;
66 typedef int SocketHandleImplementation;
67 #ifndef INVALID_SOCKET
68 #define INVALID_SOCKET -1
71 #define SOCKET_ERROR -1
96 SocketHandle(SocketHandleImplementation OSHandle = INVALID_SOCKET) :
100 #if defined(MEZZ_WINDOWS)
106 operator SOCKET()
const
108 #elif defined(MEZZ_MACOSX) || defined(MEZZ_LINUX)
122 Sol_IPv4 = IPPROTO_IP,
123 Sol_IPv6 = IPPROTO_IPV6,
124 Sol_TCP = IPPROTO_TCP,
125 Sol_UDP = IPPROTO_UDP,
126 Sol_Socket = SOL_SOCKET
133 SockOpts_Broadcast = SO_BROADCAST,
135 SockOpts_KeepAlive = SO_KEEPALIVE,
137 SockOpts_DebugInfo = SO_DEBUG,
138 SockOpts_DontRoute = SO_DONTROUTE,
139 SockOpts_ReuseAddress = SO_REUSEADDR,
140 SockOpts_RecieveBufSize = SO_RCVBUF,
141 SockOpts_SendBufSize = SO_SNDBUF
147 TCPOpts_NoDelay = TCP_NODELAY
161 #if defined(MEZZ_WINDOWS)
162 IPv4Opts_Fragmentation = IP_DONTFRAGMENT,
163 #elif defined(MEZZ_MACOSX)
165 #elif defined(MEZZ_LINUX)
166 IPv4Opts_Fragmentation = IP_MTU_DISCOVER,
169 IPv4Opts_MulticastLoop = IP_MULTICAST_LOOP,
170 IPv4Opts_MulticastTTL = IP_MULTICAST_TTL,
173 IPv4Opts_OptionsHeader = IP_OPTIONS,
174 IPv4Opts_TimeToLive = IP_TTL
180 #if defined(MEZZ_WINDOWS)
183 #elif defined(MEZZ_MACOSX)
185 #elif defined(MEZZ_LINUX)
186 MFV_Frag_Enable = IP_PMTUDISC_DONT,
187 MFV_Frag_Disable = IP_PMTUDISC_DO
197 IPv6Opts_MulticastHops = IPV6_MULTICAST_HOPS,
198 IPv6Opts_MulticastLoop = IPV6_MULTICAST_LOOP,
200 IPv6Opts_UnicastHops = IPV6_UNICAST_HOPS,
201 IPv6Opts_V6Only = IPV6_V6ONLY
301 Boole Bind(sockaddr* Address,
const AddrLen Length);
306 Boole Shutdown(
const int How);
319 Boole Connect(sockaddr* Address,
const AddrLen Length);
324 Boole Listen(
const int Backlog = 5);
367 Integer SendTo(
const void* Buffer,
const Integer BufSize,
const Integer Flags,
const sockaddr* Address,
const AddrLen Length);
383 Integer ReceiveFrom(
void* Buffer,
const Integer BufSize,
const Integer Flags, sockaddr* Address, AddrLen* Length);
394 Boole GetBlocking()
const;
400 Integer GetNumBytesAvailable()
const;
403 Boole IsInvalid()
const;
411 Boole SetSocketOption(
const Integer Level,
const Integer OptID,
const char* Value,
const AddrLen ValueLen);
418 Boole GetSocketOption(
const Integer Level,
const Integer OptID,
char* Value, AddrLen* ValueLen)
const;
425 static int GetLastError();
428 static void ThrowError(
const int ErrorCode);
430 static void ThrowLastError();
int ConvertLayer4ProtocolType(const TransportLayerProtocol Protocol)
Converts from a Mezzanine transport protocol type to it's internal counterpart.
bool Boole
Generally acts a single bit, true or false.
sockaddr_storage ConvertToSocketStorage(const SystemAddress &MezzAddr)
Converts a Mezzanine address to a Berkeley sockets address.
TCPLevelOptions
An enum for the configurable options that exist on the TCP protocol level.
short int ConvertLayer3ProtocolType(const NetworkLayerProtocol Protocol)
Converts from a Mezzanine address protocol type to it's internal counterpart.
IPv6LevelOptions
An enum for the configurable options that exist on the IPv6 protocol level.
NetworkLayerProtocol
This is an enum listing for recognized protocols on Layer 3 of the OSI model.
int ConvertToSocketType(const TransportLayerProtocol Protocol)
Converts from a Mezzanine transport protocol type to it's internal counterpart.
int Integer
A datatype used to represent any integer close to.
SocketHandleImplementation handle
The actual handle store as a platform specific type thanks to typedefs.
SocketDescription ConvertToSocketDescription(const sockaddr_storage &BerkAddr)
Converts a Berkeley sockets address to a Mezzanine socket descriptor.
SocketHandle(SocketHandleImplementation OSHandle=INVALID_SOCKET)
Platform specific contructor.
uint16_t UInt16
An 16-bit unsigned integer.
MsgFragValues
An enum for the easy mapping of the actual values needed to toggle IPv4 fragmentation.
SocketOptionLevel
An enum for the different configurable levels of socket options.
TransportLayerProtocol
This is an enum listing for recognized protocols on Layer 4 of the OSI model.
SocketLevelOptions
An enum for the configurable options that exist on the socket level.
SystemAddress ConvertToSystemAddress(const sockaddr_storage &BerkAddr)
Converts a Berkeley sockets address to a Mezzanine address.
IPv4LevelOptions
An enum for the configurable options that exist on the IPv4 protocol level.
The bulk of the engine components go in this namspace.
Used to allow type inference on PlatformSocket constructors.
UDPLevelOptions
An enum for the configurable options that exist on the UDP protocol level.
A simple class that stores a complete set of information for establishing connections.