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

Method receive

source/core/StarTcp.cpp:63–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63size_t TcpSocket::receive(char* data, size_t size) {
64 ReadLocker locker(m_mutex);
65 checkOpen("TcpSocket::receive");
66
67 if (m_socketMode == SocketMode::Closed)
68 throw SocketClosedException("TcpSocket not open in TcpSocket::receive");
69
70 int flags = 0;
71#ifdef STAR_SYSTEM_LINUX
72 // Don't generate sigpipe
73 flags |= MSG_NOSIGNAL;
74#endif
75
76 auto r = ::recv(m_impl->socketDesc, data, size, flags);
77 if (r < 0) {
78 if (m_socketMode == SocketMode::Shutdown) {
79 throw SocketClosedException("Connection closed");
80 } else if (netErrorConnectionReset()) {
81 doShutdown();
82 throw SocketClosedException("Connection reset");
83 } else if (netErrorInterrupt()) {
84 r = 0;
85 } else {
86 throw NetworkException(strf("tcp recv error: {}", netErrorString()));
87 }
88 }
89
90 return r;
91}
92
93size_t TcpSocket::send(char const* data, size_t size) {
94 ReadLocker locker(m_mutex);

Callers

nothing calls this directly

Calls 4

netErrorConnectionResetFunction · 0.85
netErrorInterruptFunction · 0.85
strfFunction · 0.85
netErrorStringFunction · 0.85

Tested by

no test coverage detected