Receive raw buffer variant
This commit is contained in:
@@ -130,6 +130,14 @@ Socket::Recv (void)
|
||||
return Recv (std::numeric_limits<uint32_t>::max(), 0);
|
||||
}
|
||||
|
||||
int
|
||||
Socket::Recv (uint8_t* buf, uint32_t size, uint32_t flags)
|
||||
{
|
||||
Ptr<Packet> p = Recv (size, flags); // read up to "size" bytes
|
||||
memcpy (buf, p->PeekData (), p->GetSize());
|
||||
return p->GetSize ();
|
||||
}
|
||||
|
||||
int Socket::SendTo (const uint8_t* buf, uint32_t size, const Address &address)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
@@ -328,6 +328,19 @@ public:
|
||||
* 0 if the socket cannot return a next in-sequence packet.
|
||||
*/
|
||||
Ptr<Packet> Recv (void);
|
||||
/**
|
||||
* \brief Recv data (or dummy data) from the remote host
|
||||
* \param buf A pointer to a raw byte buffer to write the data to.
|
||||
* If the underlying packet was carring null (fake) data, this buffer
|
||||
* will be zeroed up to the length specified by the return value.
|
||||
* \param size Number of bytes (at most) to copy to buf
|
||||
* \param flags any flags to pass to the socket
|
||||
* \returns number of bytes copied into buf
|
||||
*
|
||||
* This is provided so as to have an API which is closer in appearance
|
||||
* to that of real network or BSD sockets.
|
||||
*/
|
||||
int Recv (uint8_t* buf, uint32_t size, uint32_t flags);
|
||||
/**
|
||||
* Return number of bytes which can be returned from one or
|
||||
* multiple calls to Recv.
|
||||
|
||||
Reference in New Issue
Block a user