[Ns-developers] Socket::Recv

Tom Henderson tomh at tomh.org
Tue Apr 29 06:29:28 PDT 2008


Gustavo Carneiro wrote:
>>
>> ---- remove previous socket receive methods
>> user: Tom Henderson <tomh at tomh.org>
>> files: examples/wifi-adhoc.cc samples/main-simple.cc
>> src/applications/packet-sink/packet-sink.cc
>> src/applications/udp-echo/udp-echo-client.cc
>> src/applications/udp-echo/udp-echo-server.cc src/node/socket.cc
>> src/node/socket.h
>> url: http://code.nsnam.org/tomh/ns-3-dev-socket-helper/rev/70b98532fe5c
> 
> 
> I was looking at:
> 
> -Experiment::ReceivePacket (Ptr<Socket> socket, Ptr<Packet> packet,
> const Address &address)
> -{
> -  m_bytesTotal += packet->GetSize ();
> +Experiment::ReceivePacket (Ptr<Socket> socket)
> +{
> +  Ptr<Packet> packet;
> +  uint32_t maxSize = std::numeric_limits<uint32_t>::max();
> +  uint32_t flags = 0;  // no flags
> +  while (packet = socket->Recv (maxSize, flags))
> +    {
> +      m_bytesTotal += packet->GetSize ();
> +    }
> 
> 
> 
> 
> May I suggest to simplify the maxSize handling a bit?  We could add an
> overloaded
> 
> socket->Recv ()
> 
> with  no parameters, meaning maximum size and no flags.  This could simplify
> some code.
> 

Yes, I agree that would be useful.

Tom


More information about the Ns-developers mailing list