}
else {
try {
- Socket s((AddressFamily)ip.sin4.sin_family, Stream);
+ Socket s(ip.sin4.sin_family, SOCK_STREAM);
s.setNonBlocking();
ComboAddress local = getQueryLocalAddress(ip.sin4.sin_family, 0);
};
-enum AddressFamily {InterNetwork=AF_INET, InterNetwork6 = AF_INET6}; //!< Supported address families
-enum SocketType {Datagram=SOCK_DGRAM,Stream=SOCK_STREAM}; //!< Supported socket families
typedef int ProtocolType; //!< Supported protocol types
//! Representation of a Socket and many of the Berkeley functions available
class Socket : public boost::noncopyable
{
-private:
- explicit Socket(int fd, AddressFamily af)
- {
- d_family=af;
- d_buflen=4096;
- d_buffer=new char[d_buflen];
- d_socket=fd;
- }
public:
- //! Construct a socket of specified AddressFamily and SocketType.
- Socket(AddressFamily af, SocketType st, ProtocolType pt=0)
+ //! Construct a socket of specified address family and socket type.
+ Socket(int af, int st, ProtocolType pt=0)
{
d_family=af;
if((d_socket=(int)socket(af,st, pt))<0)
int d_socket;
char *d_buffer;
int d_buflen;
- AddressFamily d_family;
+ int d_family;
};
class Server
{
public:
- Server(const string &localaddress, int port) : d_local(localaddress.empty() ? "0.0.0.0" : localaddress, port), d_server_socket(InterNetwork, Stream, 0) {
+ Server(const string &localaddress, int port) : d_local(localaddress.empty() ? "0.0.0.0" : localaddress, port), d_server_socket(d_local.sin4.sin_family, SOCK_STREAM, 0) {
d_server_socket.setReuseAddr();
d_server_socket.bind(d_local);
d_server_socket.listen();