diff -r 38b8549b1ad3 examples/tcp-large-transfer.cc --- a/examples/tcp-large-transfer.cc Thu Jul 03 09:44:23 2008 -0400 +++ b/examples/tcp-large-transfer.cc Thu Jul 03 11:48:11 2008 -0400 @@ -132,6 +132,7 @@ int main (int argc, char *argv[]) ApplicationContainer apps = sink.Install (n1n2.Get (1)); apps.Start (Seconds (0.0)); + apps.Stop (Seconds (60.0)); // Create a source to send packets from n0. Instead of a full Application // and the helper APIs you might see in other example files, this example diff -r 38b8549b1ad3 src/applications/packet-sink/packet-sink.cc --- a/src/applications/packet-sink/packet-sink.cc Thu Jul 03 09:44:23 2008 -0400 +++ b/src/applications/packet-sink/packet-sink.cc Thu Jul 03 11:48:11 2008 -0400 @@ -88,11 +88,17 @@ void PacketSink::StartApplication() / m_socket->SetRecvCallback (MakeCallback(&PacketSink::HandleRead, this)); m_socket->SetAcceptCallback ( MakeNullCallback, const Address &> (), - MakeNullCallback, const Address&> ()); + MakeCallback(&PacketSink::HandleAccept, this)); } void PacketSink::StopApplication() // Called at time specified by Stop { + while(!m_socketList.empty()) //these are accepted sockets, close them + { + Ptr acceptedSocket = m_socketList.front(); + m_socketList.pop_front(); + acceptedSocket->Close(); + } if (m_socket) { m_socket->Close (); @@ -117,4 +123,9 @@ void PacketSink::HandleRead (Ptr } } +void PacketSink::HandleAccept (Ptr s, const Address& from) +{ + m_socketList.push_back(s); +} + } // Namespace ns3 diff -r 38b8549b1ad3 src/applications/packet-sink/packet-sink.h --- a/src/applications/packet-sink/packet-sink.h Thu Jul 03 09:44:23 2008 -0400 +++ b/src/applications/packet-sink/packet-sink.h Thu Jul 03 11:48:11 2008 -0400 @@ -81,8 +81,13 @@ private: virtual void StopApplication (void); // Called at time specified by Stop void HandleRead (Ptr socket); + void HandleAccept (Ptr, const Address& from); - Ptr m_socket; // Associated socket + // In the case of TCP, each socket accept returns a new socket, so the + // listening socket is stored seperately from the accepted sockets + Ptr m_socket; // Listening socket + std::list > m_socketList; //the accepted sockets + Address m_local; // Local address to bind to TypeId m_tid; // Protocol TypeId TracedCallback, const Address &> m_rxTrace;