Skip to content

Commit

Permalink
[Support] Fix the Read/Write of socket stream (#17284)
Browse files Browse the repository at this point in the history
This PR fixes the `dmlc::Stream::Read/Write` for TCP socket.
Given socket does not guarantee that all data are send received/sent
in a single shot, we need to use `RecvAll/SendAll`.
  • Loading branch information
MasterJH5574 authored Aug 26, 2024
1 parent 384360f commit d5d5ebb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/support/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,9 @@ class TCPSocket : public Socket, public dmlc::Stream {
return data;
}

size_t Read(void* data, size_t size) final { return Recv(data, size); }
size_t Read(void* data, size_t size) final { return RecvAll(data, size); }

size_t Write(const void* data, size_t size) final { return Send(data, size); }
size_t Write(const void* data, size_t size) final { return SendAll(data, size); }
};

/*! \brief helper data structure to perform poll */
Expand Down

0 comments on commit d5d5ebb

Please sign in to comment.