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

Method send

source/core/StarUdp.cpp:35–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35size_t UdpSocket::send(HostAddressWithPort const& address, char const* data, size_t size) {
36 ReadLocker locker(m_mutex);
37 checkOpen("UdpSocket::send");
38
39 struct sockaddr_storage sockAddr;
40 socklen_t sockAddrLen;
41 setNativeFromAddress(address, &sockAddr, &sockAddrLen);
42
43 int len = ::sendto(m_impl->socketDesc, data, size, 0, (struct sockaddr*)&sockAddr, sockAddrLen);
44 if (len < 0) {
45 if (!isActive())
46 throw SocketClosedException("Connection closed");
47 else if (netErrorInterrupt())
48 len = 0;
49 else
50 throw NetworkException(strf("udp send error: {}", netErrorString()));
51 }
52
53 return len;
54}
55
56UdpServer::UdpServer(HostAddressWithPort const& address)
57 : m_hostAddress(address), m_listenSocket(make_shared<UdpSocket>(m_hostAddress.address().mode())) {

Callers 4

updateMethod · 0.45
updateRunningMethod · 0.45
runMethod · 0.45
TESTFunction · 0.45

Calls 4

setNativeFromAddressFunction · 0.85
netErrorInterruptFunction · 0.85
strfFunction · 0.85
netErrorStringFunction · 0.85

Tested by 2

runMethod · 0.36
TESTFunction · 0.36