MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / Send

Method Send

examples/ThirdPartyLibs/clsocket/src/SimpleSocket.cpp:377–449  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Send() - Send data on a valid socket ------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

375//
376//------------------------------------------------------------------------------
377int32 CSimpleSocket::Send(const uint8 *pBuf, size_t bytesToSend)
378{
379 SetSocketError(SocketSuccess);
380 m_nBytesSent = 0;
381
382 switch (m_nSocketType)
383 {
384 case CSimpleSocket::SocketTypeTcp:
385 {
386 if (IsSocketValid())
387 {
388 if ((bytesToSend > 0) && (pBuf != NULL))
389 {
390 m_timer.Initialize();
391 m_timer.SetStartTime();
392
393 //---------------------------------------------------------
394 // Check error condition and attempt to resend if call
395 // was interrupted by a signal.
396 //---------------------------------------------------------
397 do
398 {
399 m_nBytesSent = SEND(m_socket, pBuf, bytesToSend, 0);
400 TranslateSocketError();
401 } while (GetSocketError() == CSimpleSocket::SocketInterrupted);
402
403 m_timer.SetEndTime();
404 }
405 }
406 break;
407 }
408 case CSimpleSocket::SocketTypeUdp:
409 {
410 if (IsSocketValid())
411 {
412 if ((bytesToSend > 0) && (pBuf != NULL))
413 {
414 m_timer.Initialize();
415 m_timer.SetStartTime();
416
417 //---------------------------------------------------------
418 // Check error condition and attempt to resend if call
419 // was interrupted by a signal.
420 //---------------------------------------------------------
421 // if (GetMulticast())
422 // {
423 // do
424 // {
425 // m_nBytesSent = SENDTO(m_socket, pBuf, bytesToSend, 0, (const sockaddr *)&m_stMulticastGroup,
426 // sizeof(m_stMulticastGroup));
427 // TranslateSocketError();
428 // } while (GetSocketError() == CSimpleSocket::SocketInterrupted);
429 // }
430 // else
431 {
432 do
433 {
434 m_nBytesSent = SENDTO(m_socket, pBuf, bytesToSend, 0, (const sockaddr *)&m_stServerSockaddr, sizeof(m_stServerSockaddr));

Callers 9

connectTCPMethod · 0.45
processCommandMethod · 0.45
disconnectMethod · 0.45
submitClientCommandMethod · 0.45
connectMethod · 0.45
disconnectMethod · 0.45
uploadDataMethod · 0.45
submitStatusFunction · 0.45
mainFunction · 0.45

Calls 3

SetStartTimeMethod · 0.80
SetEndTimeMethod · 0.80
InitializeMethod · 0.45

Tested by

no test coverage detected