00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00039 #ifndef BLOCXX_NETWORK_TYPES_HPP_INCLUDE_GUARD_
00040 #define BLOCXX_NETWORK_TYPES_HPP_INCLUDE_GUARD_
00041 #include "blocxx/BLOCXX_config.h"
00042 #include "blocxx/Types.hpp"
00043
00044 extern "C"
00045 {
00046 #ifdef BLOCXX_HAVE_UNISTD_H
00047 #include <unistd.h>
00048 #endif
00049
00050 #include <signal.h>
00051
00052 #ifdef BLOCXX_HAVE_SYS_SOCKET_H
00053 #include <sys/socket.h>
00054 #endif
00055
00056 #ifdef BLOCXX_HAVE_NETINET_IN_H
00057 #include <netinet/in.h>
00058 #endif
00059
00060 #ifdef BLOCXX_HAVE_SYS_UN_H
00061 #include <sys/un.h>
00062 #endif
00063
00064 #if defined(BLOCXX_WIN32)
00065 #include <winsock2.h>
00066 #endif
00067 }
00068
00069 #undef shutdown // On OpenUnix, sys/socket.h defines shutdown to be
00070
00071
00072 namespace BLOCXX_NAMESPACE
00073 {
00074
00075
00076 typedef sockaddr SocketAddress_t;
00077
00078 #ifdef BLOCXX_HAVE_IPV6
00079 typedef sockaddr_storage InetSocketAddress_t;
00080 #else
00081 typedef sockaddr_in InetSocketAddress_t;
00082 #endif
00083
00084 #if !defined(BLOCXX_WIN32)
00085
00086 typedef sockaddr_un UnixSocketAddress_t;
00087 #endif
00088
00089
00090 typedef in_addr InetAddress_t;
00091
00092 #if defined (BLOCXX_WIN32)
00093
00094 typedef SOCKET SocketHandle_t;
00095 #else
00096
00097 typedef int SocketHandle_t;
00098 #endif
00099
00100
00101
00102 #if defined(BLOCXX_WIN32)
00103 struct Select_t
00104 {
00105 Select_t()
00106 : event(NULL)
00107 , descriptor(INVALID_HANDLE_VALUE)
00108 , sockfd(INVALID_SOCKET)
00109 , isSocket(false)
00110 , networkevents(0)
00111 , doreset(false)
00112 {
00113 }
00114
00115 Select_t(const Select_t& arg)
00116 : event(arg.event)
00117 , descriptor(arg.descriptor)
00118 , sockfd(arg.sockfd)
00119 , isSocket(arg.isSocket)
00120 , networkevents(arg.networkevents)
00121 , doreset(arg.doreset)
00122 {
00123 }
00124
00125 HANDLE event;
00126 HANDLE descriptor;
00127 SOCKET sockfd;
00128 bool isSocket;
00129 bool doreset;
00130 long networkevents;
00131
00132 bool operator<(const Select_t& s1) const
00133 {
00134
00135
00136
00137 return (event < s1.event);
00138 }
00139
00140 bool operator==(const Select_t& s1) const
00141 {
00142 return (event == s1.event);
00143 }
00144 };
00145 #else
00146 typedef int Select_t;
00147 #endif
00148
00149 }
00150
00151 #if defined(BLOCXX_WIN32) || defined(BLOCXX_NCR)
00152 typedef int socklen_t;
00153 #else
00154 #ifndef BLOCXX_HAVE_SOCKLEN_T
00155 typedef unsigned socklen_t;
00156 #endif
00157 #endif
00158
00159
00160 #endif