///////////////////////////////////////////////////////
| 101 | |
| 102 | //////////////////////////////////////////////////////////// |
| 103 | void Socket::create(IpAddress::Type addressType) |
| 104 | { |
| 105 | // Don't create the socket if it already exists |
| 106 | if (m_socket == priv::SocketImpl::invalidSocket()) |
| 107 | { |
| 108 | const SocketHandle handle = socket(addressType == IpAddress::Type::IpV4 ? PF_INET : PF_INET6, |
| 109 | m_type == Type::Tcp ? SOCK_STREAM : SOCK_DGRAM, |
| 110 | 0); |
| 111 | |
| 112 | if (handle == priv::SocketImpl::invalidSocket()) |
| 113 | { |
| 114 | err() << "Failed to create socket" << std::endl; |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | create(handle); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | |
| 123 | //////////////////////////////////////////////////////////// |