--- a/src/node/socket.cc Mon May 26 11:07:41 2008 -0700
+++ b/src/node/socket.cc Mon May 26 11:22:42 2008 -0700
@@ -130,6 +130,14 @@
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 ();
--- a/src/node/socket.h Mon May 26 11:07:41 2008 -0700
+++ b/src/node/socket.h Mon May 26 11:22:42 2008 -0700
@@ -329,6 +329,19 @@
*/
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.
* Must be possible to call this method from the Recv callback.