MCPcopy Create free account
hub / github.com/SpartanJ/eepp / receive

Method receive

src/eepp/network/tcpsocket.cpp:213–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213Socket::Status TcpSocket::receive( void* data, std::size_t size, std::size_t& received ) {
214 // First clear the variables to fill
215 received = 0;
216
217 // Check the destination buffer
218 if ( !data ) {
219 Log::error( "Cannot receive data from the network (the destination buffer is invalid)" );
220 return Error;
221 }
222
223 // Receive a chunk of bytes
224 int sizeReceived =
225 recv( getHandle(), static_cast<char*>( data ), static_cast<int>( size ), flags );
226
227 // Check the number of bytes received
228 if ( sizeReceived > 0 ) {
229 received = static_cast<std::size_t>( sizeReceived );
230 return Done;
231 } else if ( sizeReceived == 0 ) {
232 return Socket::Disconnected;
233 } else {
234 return Private::SocketImpl::getErrorStatus();
235 }
236}
237
238Socket::Status TcpSocket::send( Packet& packet ) {
239 // TCP is a stream protocol, it doesn't preserve messages boundaries.

Callers

nothing calls this directly

Calls 9

errorFunction · 0.85
getHandleFunction · 0.85
eeminFunction · 0.85
PendingPacketClass · 0.85
clearMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
emptyMethod · 0.45
onReceiveMethod · 0.45

Tested by

no test coverage detected