MCPcopy Create free account
hub / github.com/MonaSolutions/MonaServer / sendBytes

Method sendBytes

MonaBase/sources/Socket.cpp:292–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290
291
292 int sendBytes(Exception& ex, const void* buffer, int length, int flags) {
293 ASSERT_RETURN(_initialized, 0);
294
295#if defined(MSG_NOSIGNAL)
296 flags |= MSG_NOSIGNAL;
297#endif
298
299 int rc;
300 do {
301 rc = ::send(_sockfd, reinterpret_cast<const char*>(buffer), length, flags);
302 } while (rc < 0 && Net::LastError() == NET_EINTR);
303
304 if (rc < 0) {
305 int err = Net::LastError();
306 if (err == NET_EAGAIN || err == NET_EWOULDBLOCK || (err == NET_ENOTCONN && _connecting))
307 rc = 0;
308 else
309 Net::SetException(ex, err," (length=",length,", flags=",flags,")");
310 }
311 if (rc >= 0) {
312 if (rc > 0) {
313 lock_guard<recursive_mutex> lock(_mutexManaged);
314 if (_pSocket)
315 _pSocket->OnSending::raise((UInt32)rc);
316 }
317 lock_guard<mutex> lock(_mutexAsync);
318 _connecting = false;
319 }
320 return rc;
321 }
322
323
324 int receiveBytes(Exception& ex, void* buffer, int length, int flags) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected