+ Impl(const SocketAddress& address, int flags = 0) :
+ address(address),
+ fd(::socket(address.family(), address.type(), flags)),
+ isConnected(false) {}
+ } mImpl;
+
+
+public:
+
+ /**
+ * Construct a socket with no associated peer.
+ */
+ Socket() {}
+
+ /**
+ * Construct a socket with an address.
+ * \param address The address.
+ * \param flags The socket options.
+ */
+ Socket(const SocketAddress& address, int flags = 0) :
+ mImpl(address, flags) {}
+
+ /**
+ * Construct a socket with a specified host. The socket can be used to
+ * connect to a host.
+ * \param service The service name or port number.
+ * \param host The numeric IP address of the host.
+ * \param type The type of socket; either SOCK_STREAM or SOCK_DGRAM.
+ * \param family The family; can be AF_INET or AF_INET6.
+ * \param flags The socket options.
+ */
+ Socket(const std::string& service, const std::string& name,
+ int type = SOCK_STREAM, int family = AF_UNSPEC,
+ int flags = 0) :
+ mImpl(SocketAddress(service, name, type, family), flags) {}
+
+ /**
+ * Construct a socket without a specified host. The socket can be used
+ * to accept sockets on a local port.
+ * \param service The service name or port number.
+ * \param type The type of socket; either SOCK_STREAM or SOCK_DGRAM.
+ * \param family The family; can be AF_INET or AF_INET6.
+ * \param flags The socket options.
+ */
+ Socket(const std::string& service, int type = SOCK_STREAM,
+ int family = AF_UNSPEC, int flags = 0) :
+ mImpl(SocketAddress(service, type, family), flags) {}
+
+
+ /**
+ * Deconstruct the socket, closing it.
+ */