| 209 | } |
| 210 | |
| 211 | Socket::Socket(SocketType type, NetworkMode networkMode) |
| 212 | : m_networkMode(networkMode), m_impl(make_shared<SocketImpl>()), m_socketMode(SocketMode::Closed) { |
| 213 | if (m_networkMode == NetworkMode::IPv4) |
| 214 | m_impl->socketDesc = ::socket(AF_INET, type == SocketType::Tcp ? SOCK_STREAM : SOCK_DGRAM, 0); |
| 215 | else |
| 216 | m_impl->socketDesc = ::socket(AF_INET6, type == SocketType::Tcp ? SOCK_STREAM : SOCK_DGRAM, 0); |
| 217 | |
| 218 | if (invalidSocketDescriptor(m_impl->socketDesc)) |
| 219 | throw NetworkException(strf("cannot create socket: {}", netErrorString())); |
| 220 | |
| 221 | m_socketMode = SocketMode::Shutdown; |
| 222 | setTimeout(60000); |
| 223 | setNonBlocking(false); |
| 224 | } |
| 225 | |
| 226 | Socket::Socket(NetworkMode networkMode, SocketImplPtr impl, SocketMode socketMode) |
| 227 | : m_networkMode(networkMode), m_impl(impl), m_socketMode(socketMode) { |
nothing calls this directly
no test coverage detected