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 
00009 // -- do platform includes and typedefs
00010 
00011 #if defined(WIN32) // msvc - 32 bit
00012 
00013 #include <Winsock2.h>
00014 #undef SetPort //wow
00015 
00016 typedef int socklen_t;
00017 
00018 #elif defined(linux)  // g++ - 32 bit
00019 
00020 #include <sys/socket.h>
00021 #include <arpa/inet.h>
00022 #include <netdb.h>
00023 #include <netinet/tcp.h>
00024 
00025 #else // ?
00026 
00027     #error Unknown platform in PlatformSockets.h
00028 
00029 #endif
00030 
00031 // -- functions we have to abstract
00032 
00033 namespace NET
00034 {
00035     //sets a socket to be blocking or nonblocking
00036     bool Internal_SetSocketBlocking(int sock, bool block);
00037 
00038     //gets a string that represents a socket error for the most recent operation
00039     std::string Internal_GetLastError();
00040 
00041     //closes a socket
00042     void Internal_CloseSocket(int sock);
00043 
00044     //returns whether the error from the most recent socket operations indicates a loss of connection, or whether the socket was nicely closed
00045     bool Internal_IsLastSocketErrorADisconnect();
00046 }

Generated on Wed Feb 13 20:57:04 2008 for MPMA Framework by  doxygen 1.5.4