00001 // -*- Socket Streams -*- 00002 00003 // Copyright (C) 2003, 2004, 2005 Pedro LamarĂ£o <pedro.lamarao@mndfck.org> 00004 00005 // This file is part of the Socket Streams Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU Lesser General Public License as published by the 00008 // Free Software Foundation; either version 2.1 of the License 00009 // or (at your option) any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU Lesser General Public License for more details. 00015 00016 // You should have received a copy of the GNU Lesser General Public License along 00017 // with this library; see the file COPYING. If not, write to the Free 00018 // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, 00019 // USA 00020 00025 #ifndef SOCKETSTREAM_SOCKETS_BASE_H 00026 #define SOCKETSTREAM_SOCKETS_BASE_H 1 00027 00028 #include <socketstream/config.h> 00029 00030 #ifndef WIN32 00031 # include <sys/types.h> 00032 # include <sys/socket.h> 00033 #endif 00034 00039 namespace ss { 00040 00041 enum __Family { }; 00042 enum __Style { }; 00043 enum __Protocol { }; 00044 enum __Shutdown_Mode { }; 00045 enum __Io_Flag { }; 00046 00047 inline __Io_Flag 00048 operator& (__Io_Flag __a, __Io_Flag __b) 00049 { return __Io_Flag(static_cast<int>(__a) & static_cast<int>(__b)); } 00050 00051 inline __Io_Flag 00052 operator| (__Io_Flag __a, __Io_Flag __b) 00053 { return __Io_Flag(static_cast<int>(__a) | static_cast<int>(__b)); } 00054 00055 inline __Io_Flag 00056 operator^ (__Io_Flag __a, __Io_Flag __b) 00057 { return __Io_Flag(static_cast<int>(__a) ^ static_cast<int>(__b)); } 00058 00059 inline __Io_Flag 00060 operator&= (__Io_Flag __a, __Io_Flag __b) 00061 { return __a = __a & __b; } 00062 00063 inline __Io_Flag 00064 operator|= (__Io_Flag __a, __Io_Flag __b) 00065 { return __a = __a | __b; } 00066 00067 inline __Io_Flag 00068 operator^= (__Io_Flag __a, __Io_Flag __b) 00069 { return __a = __a ^ __b; } 00070 00071 inline __Io_Flag 00072 operator~ (__Io_Flag __a) 00073 { return __Io_Flag(~static_cast<int>(__a)); } 00074 00080 class SOCKETSTREAM_API sockets_base { 00081 public: 00082 00088 #ifdef WIN32 00089 typedef SOCKET socket_type; 00090 typedef SOCKET descriptor_t; 00091 #else 00092 typedef int socket_type; 00093 typedef int descriptor_t; 00094 #endif 00095 00102 typedef __Family family; 00103 00110 typedef __Style style; 00111 00115 typedef __Protocol protocol; 00116 00123 typedef __Shutdown_Mode shutmode; 00124 00131 typedef __Io_Flag flag; 00132 00139 struct SOCKETSTREAM_API def 00140 { 00141 static const sockets_base::family family; 00142 static const sockets_base::style style; 00143 static const sockets_base::protocol protocol; 00144 static const sockets_base::flag flag; 00145 }; 00146 00147 static const family local; 00148 static const family ipv4; 00149 static const family ipv6; 00150 static const family netlink; 00151 static const family packet; 00152 00153 static const style stream; 00154 static const style datagram; 00155 static const style raw; 00156 static const style rdm; 00157 static const style seqpacket; 00158 00159 static const shutmode r; 00160 static const shutmode w; 00161 static const shutmode rw; 00162 00163 static const flag oob; 00164 static const flag dontroute; 00165 static const flag dontwait; 00166 static const flag nosignal; 00167 static const flag peek; 00168 static const flag waitall; 00169 static const flag trunc; 00170 static const flag errqueue; 00171 00172 }; 00173 } 00174 00175 #endif // SOCKETSTREAM_SOCKETS_BASE_H