remove previous socket receive methods
authorTom Henderson <tomh@tomh.org>
Mon, 28 Apr 2008 21:45:55 -0700
changeset 3100 70b98532fe5c
parent 3099 99ab4885e124
child 3101 21ec0bc2063e
remove previous socket receive methods
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
--- a/examples/wifi-adhoc.cc	Mon Apr 28 21:33:15 2008 -0700
+++ b/examples/wifi-adhoc.cc	Mon Apr 28 21:45:55 2008 -0700
@@ -38,7 +38,7 @@
   Experiment (std::string name);
   GnuplotDataset Run (const WifiHelper &wifi);
 private:
-  void ReceivePacket (Ptr<Socket> socket, Ptr<Packet> packet, const Address &address);
+  void ReceivePacket (Ptr<Socket> socket);
   void SetPosition (Ptr<Node> node, Vector position);
   Vector GetPosition (Ptr<Node> node);
   void AdvancePosition (Ptr<Node> node);
@@ -90,9 +90,15 @@
 }
 
 void
-Experiment::ReceivePacket (Ptr<Socket> socket, Ptr<Packet> packet, const Address &address)
+Experiment::ReceivePacket (Ptr<Socket> socket)
 {
-  m_bytesTotal += packet->GetSize ();
+  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 ();
+    }
 }
 
 Ptr<Socket>
@@ -102,7 +108,7 @@
   Ptr<SocketFactory> socketFactory = node->GetObject<SocketFactory> (tid);
   Ptr<Socket> sink = socketFactory->CreateSocket ();
   sink->Bind ();
-  sink->SetRecvCallback (MakeCallback (&Experiment::ReceivePacket, this));
+  sink->SetRecv_Callback (MakeCallback (&Experiment::ReceivePacket, this));
   return sink;
 }
 
--- a/samples/main-simple.cc	Mon Apr 28 21:33:15 2008 -0700
+++ b/samples/main-simple.cc	Mon Apr 28 21:45:55 2008 -0700
@@ -23,15 +23,21 @@
 }
 
 static void
-SocketPrinter (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from)
+SocketPrinter (Ptr<Socket> socket)
 {
-  std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, rx bytes=" << packet->GetSize () << std::endl;
+  Ptr<Packet> packet;
+  uint32_t maxSize = std::numeric_limits<uint32_t>::max();
+  uint32_t flags = 0;  // no flags
+  while (packet = socket->Recv (maxSize, flags))
+    { 
+      std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, rx bytes=" << packet->GetSize () << std::endl;
+    }
 }
 
 static void
 PrintTraffic (Ptr<Socket> socket)
 {
-  socket->SetRecvCallback (MakeCallback (&SocketPrinter));
+  socket->SetRecv_Callback (MakeCallback (&SocketPrinter));
 }
 
 void
--- a/src/applications/packet-sink/packet-sink.cc	Mon Apr 28 21:33:15 2008 -0700
+++ b/src/applications/packet-sink/packet-sink.cc	Mon Apr 28 21:45:55 2008 -0700
@@ -87,7 +87,6 @@
       m_socket->Listen (0);
     }
 
-  m_socket->SetRecvCallback (MakeCallback(&PacketSink::Receive, this));
   m_socket->SetRecv_Callback (MakeCallback(&PacketSink::HandleRead, this));
   m_socket->SetAcceptCallback (
             MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
@@ -99,8 +98,7 @@
 {
   if (m_socket) 
     {
-      m_socket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket>, 
-        Ptr<Packet>, const Address &> ());
+      m_socket->SetRecv_Callback (MakeNullCallback<void, Ptr<Socket> > ());
     }
 }
 
--- a/src/applications/udp-echo/udp-echo-client.cc	Mon Apr 28 21:33:15 2008 -0700
+++ b/src/applications/udp-echo/udp-echo-client.cc	Mon Apr 28 21:45:55 2008 -0700
@@ -115,8 +115,7 @@
 
   if (!m_socket) 
     {
-      m_socket->SetRecvCallback(MakeNullCallback<void, Ptr<Socket>, Ptr<Packet>,
-                                const Address &> ());
+      m_socket->SetRecv_Callback(MakeNullCallback<void, Ptr<Socket> > ());
     }
 
   Simulator::Cancel(m_sendEvent);
--- a/src/applications/udp-echo/udp-echo-server.cc	Mon Apr 28 21:33:15 2008 -0700
+++ b/src/applications/udp-echo/udp-echo-server.cc	Mon Apr 28 21:45:55 2008 -0700
@@ -79,7 +79,6 @@
       m_socket->Bind (local);
     }
 
-  //m_socket->SetRecvCallback(MakeCallback(&UdpEchoServer::Receive, this));
   m_socket->SetRecv_Callback(MakeCallback(&UdpEchoServer::HandleRead, this));
 }
 
@@ -90,8 +89,7 @@
 
   if (!m_socket) 
     {
-      m_socket->SetRecvCallback(MakeNullCallback<void, Ptr<Socket>, 
-        Ptr<Packet>, const Address &> ());
+      m_socket->SetRecv_Callback(MakeNullCallback<void, Ptr<Socket> > ());
     }
 }
 
--- a/src/node/socket.cc	Mon Apr 28 21:33:15 2008 -0700
+++ b/src/node/socket.cc	Mon Apr 28 21:45:55 2008 -0700
@@ -80,13 +80,6 @@
 }
 
 void 
-Socket::SetRecvCallback (Callback<void, Ptr<Socket>, Ptr<Packet>,const Address&> receivedData)
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  m_receivedData = receivedData;
-}
-
-void 
 Socket::SetRecv_Callback (Callback<void, Ptr<Socket> > receivedData)
 {
   NS_LOG_FUNCTION_NOARGS ();
@@ -228,16 +221,6 @@
 }
 
 void 
-Socket::NotifyDataReceived (Ptr<Packet> p, const Address &from)
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  if (!m_receivedData.IsNull ())
-    {
-      m_receivedData (this, p, from);
-    }
-}
-
-void 
 Socket::NotifyDataRecv (void)
 {
   NS_LOG_FUNCTION_NOARGS ();
--- a/src/node/socket.h	Mon Apr 28 21:33:15 2008 -0700
+++ b/src/node/socket.h	Mon Apr 28 21:45:55 2008 -0700
@@ -157,13 +157,6 @@
    * \param receivedData Invoked whenever new data is received.
    *
    */
-  void SetRecvCallback (Callback<void, Ptr<Socket>, Ptr<Packet>,
-                          const Address&> receivedData);
-  /**
-   * \brief Receive data
-   * \param receivedData Invoked whenever new data is received.
-   *
-   */
   void SetRecv_Callback (Callback<void, Ptr<Socket> >);
   /** 
    * \param address the address to try to allocate
@@ -279,7 +272,6 @@
   void NotifyCloseRequested (void);
   void NotifyDataSent (uint32_t size);
   void NotifySend (uint32_t spaceAvailable);
-  void NotifyDataReceived (Ptr<Packet> p, const Address &from);
   void NotifyDataRecv (void);
 
   Callback<void,Ptr<Socket> >    m_closeCompleted;
@@ -291,7 +283,6 @@
   Callback<void, Ptr<Socket>, const Address&>    m_newConnectionCreated;
   Callback<void, Ptr<Socket>, uint32_t>          m_dataSent;
   Callback<void, Ptr<Socket>, uint32_t >         m_sendCb;
-  Callback<void, Ptr<Socket>, Ptr<Packet>,const Address&> m_receivedData;
   Callback<void, Ptr<Socket> > m_receivedData_;
 };