| 603 | |
| 604 | |
| 605 | bool cSocketThreads::cSocketThread::SendDataThroughSocket(cSocket & a_Socket, AString & a_Data) |
| 606 | { |
| 607 | // Send data in smaller chunks, so that the OS send buffers aren't overflown easily |
| 608 | while (!a_Data.empty()) |
| 609 | { |
| 610 | size_t NumToSend = std::min(a_Data.size(), (size_t)1024); |
| 611 | int Sent = a_Socket.Send(a_Data.data(), NumToSend); |
| 612 | if (Sent < 0) |
| 613 | { |
| 614 | int Err = cSocket::GetLastError(); |
| 615 | if (Err == cSocket::ErrWouldBlock) |
| 616 | { |
| 617 | // The OS send buffer is full, leave the outgoing data for the next time |
| 618 | return true; |
| 619 | } |
| 620 | // An error has occured |
| 621 | return false; |
| 622 | } |
| 623 | if (Sent == 0) |
| 624 | { |
| 625 | a_Socket.CloseSocket(); |
| 626 | return true; |
| 627 | } |
| 628 | a_Data.erase(0, Sent); |
| 629 | } |
| 630 | return true; |
| 631 | } |
| 632 | |
| 633 | |
| 634 |
nothing calls this directly
no test coverage detected