MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / Socket

Method Socket

source/core/StarSocket.cpp:211–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211Socket::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
226Socket::Socket(NetworkMode networkMode, SocketImplPtr impl, SocketMode socketMode)
227 : m_networkMode(networkMode), m_impl(impl), m_socketMode(socketMode) {

Callers

nothing calls this directly

Calls 3

invalidSocketDescriptorFunction · 0.85
strfFunction · 0.85
netErrorStringFunction · 0.85

Tested by

no test coverage detected