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

Method sendTo

MonaBase/sources/Socket.cpp:346–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344
345
346 int sendTo(Exception& ex, const void* buffer, int length, const SocketAddress& address, bool allowBroadcast,int flags) {
347 if (!_initialized && !init(ex, address.family()))
348 return 0;
349
350 managed(ex); // ex is warning here
351
352 if (allowBroadcast && address.host().isAnyBroadcast())
353 setOption(ex, SOL_SOCKET, SO_BROADCAST,1); // ex is warning here
354
355#if defined(MSG_NOSIGNAL)
356 flags |= MSG_NOSIGNAL;
357#endif
358
359 int rc;
360 do {
361 rc = ::sendto(_sockfd, (const char*)buffer, length, flags, address.addr(), address.size());
362 } while (rc < 0 && Net::LastError() == NET_EINTR);
363 if (rc < 0) {
364 int err = Net::LastError();
365 if (err == NET_EAGAIN || err == NET_EWOULDBLOCK)
366 return 0;
367 Net::SetException(ex, err," (length=",length,", flags=",flags,", address=",address.toString(),")");
368 }
369 else if (rc > 0) {
370 lock_guard<recursive_mutex> lock(_mutexManaged);
371 if (_pSocket)
372 _pSocket->OnSending::raise((UInt32)rc);
373 }
374
375 return rc;
376 }
377
378
379 int receiveFrom(Exception& ex, void* buffer, int length, SocketAddress& address, int flags) {

Callers

nothing calls this directly

Calls 4

familyMethod · 0.45
isAnyBroadcastMethod · 0.45
addrMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected