PlatformSockets.h

00001 //includes whatever files are needed to access the platform's socket implementation and provides helpers for platform-specific socket operations.
00002 //this is meant for internal framework use only.
00003 //Luke Lenhart, 2008
00004 //See /docs/License.txt for details on how this code may be used.
00005 
00006 #pragma once
00007 #include <string>
00008 #include "../base/Types.h"
00009 
00010 // -- do platform includes and typedefs
00011 
00012 #if defined(WIN32) // msvc - 32 bit
00013 
00014 #include <Winsock2.h>
00015 #undef SetPort //wow
00016 
00017 typedef int socklen_t;
00018 
00019 #elif defined(linux)  // g++ - 32 bit
00020 
00021 #include <sys/socket.h>
00022 #include <arpa/inet.h>
00023 #include <netdb.h>
00024 #include <netinet/tcp.h>
00025 
00026 #else // ?
00027 
00028     #error Unknown platform in PlatformSockets.h
00029 
00030 #endif
00031 
00032 // -- functions we have to abstract
00033 
00034 namespace NET_INTERNAL
00035 {
00036     //sets a socket to be blocking or nonblocking
00037     bool Internal_SetSocketBlocking(int sock, bool block);
00038 
00039     //clears any previous error codes set
00040     void Internal_ClearLastError();
00041 
00042     //gets a string that represents a socket error for the most recent operation
00043     std::string Internal_GetLastError();
00044 
00045     //closes a socket
00046     void Internal_CloseSocket(int sock);
00047 
00048     //returns whether the error from the most recent socket operations indicates a loss of connection, or whether the socket was nicely closed
00049     bool Internal_IsLastSocketErrorADisconnect();
00050 
00051     //gets our subnet mask and subnet address
00052     bool Internal_GetSubnet(uint32 &mask, uint32 &net, uint32 &localIp);
00053 }

Generated on Sat Aug 9 15:05:05 2008 for MPMA Framework by  doxygen 1.5.6