Skip to content

Commit

Permalink
fix: tcp packet fragmentation (#700)
Browse files Browse the repository at this point in the history
* fix: tcp packet fragmentation

* solve sonar issue
  • Loading branch information
andjordan authored Aug 31, 2024
1 parent 99a068c commit c419e54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions services/network_instantiations/ConnectionBsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ namespace services

void ConnectionBsd::Send()
{
int sent = 0;
long sent = 0;

do
{
sent = send(socket, reinterpret_cast<char*>(sendBuffer.contiguous_range(sendBuffer.begin()).begin()), sendBuffer.contiguous_range(sendBuffer.begin()).size(), 0);
std::vector<char> tmpBuffer(sendBuffer.begin(), sendBuffer.end());
sent = send(socket, tmpBuffer.data(), tmpBuffer.size(), 0);

if (sent == -1)
{
Expand Down
3 changes: 2 additions & 1 deletion services/network_instantiations/ConnectionWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ namespace services
do
{
UpdateEventFlags(); // If there is something to send, update the flags before calling send, because FD_SEND is an edge-triggered event.
sent = send(socket, reinterpret_cast<char*>(sendBuffer.contiguous_range(sendBuffer.begin()).begin()), sendBuffer.contiguous_range(sendBuffer.begin()).size(), 0);
std::vector<char> tmpBuffer(sendBuffer.begin(), sendBuffer.end());
sent = send(socket, tmpBuffer.data(), tmpBuffer.size(), 0);

if (sent == SOCKET_ERROR)
{
Expand Down

0 comments on commit c419e54

Please sign in to comment.