View | Details | Raw Unified | Return to bug 244
Collapse All | Expand All

(-)a/examples/tcp-large-transfer.cc (+1 lines)
 Lines 132-137   int main (int argc, char *argv[]) Link Here 
132
132
133
  ApplicationContainer apps = sink.Install (n1n2.Get (1));
133
  ApplicationContainer apps = sink.Install (n1n2.Get (1));
134
  apps.Start (Seconds (0.0));
134
  apps.Start (Seconds (0.0));
135
  apps.Stop (Seconds (60.0));
135
136
136
  // Create a source to send packets from n0.  Instead of a full Application
137
  // Create a source to send packets from n0.  Instead of a full Application
137
  // and the helper APIs you might see in other example files, this example
138
  // and the helper APIs you might see in other example files, this example
(-)a/src/applications/packet-sink/packet-sink.cc (-1 / +12 lines)
 Lines 88-98   void PacketSink::StartApplication() / Link Here 
88
  m_socket->SetRecvCallback (MakeCallback(&PacketSink::HandleRead, this));
88
  m_socket->SetRecvCallback (MakeCallback(&PacketSink::HandleRead, this));
89
  m_socket->SetAcceptCallback (
89
  m_socket->SetAcceptCallback (
90
            MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
90
            MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
91
            MakeNullCallback<void, Ptr<Socket>, const Address&> ());
91
            MakeCallback(&PacketSink::HandleAccept, this));
92
}
92
}
93
93
94
void PacketSink::StopApplication()     // Called at time specified by Stop
94
void PacketSink::StopApplication()     // Called at time specified by Stop
95
{
95
{
96
  while(!m_socketList.empty()) //these are accepted sockets, close them
97
  {
98
    Ptr<Socket> acceptedSocket = m_socketList.front();
99
    m_socketList.pop_front();
100
    acceptedSocket->Close();
101
  }
96
  if (m_socket) 
102
  if (m_socket) 
97
    {
103
    {
98
      m_socket->Close ();
104
      m_socket->Close ();
 Lines 117-120   void PacketSink::HandleRead (Ptr<Socket> Link Here 
117
    }
123
    }
118
}
124
}
119
125
126
void PacketSink::HandleAccept (Ptr<Socket> s, const Address& from)
127
{
128
  m_socketList.push_back(s);
129
}
130
120
} // Namespace ns3
131
} // Namespace ns3
(-)a/src/applications/packet-sink/packet-sink.h (-1 / +6 lines)
 Lines 81-88   private: Link Here 
81
  virtual void StopApplication (void);     // Called at time specified by Stop
81
  virtual void StopApplication (void);     // Called at time specified by Stop
82
82
83
  void HandleRead (Ptr<Socket> socket);
83
  void HandleRead (Ptr<Socket> socket);
84
  void HandleAccept (Ptr<Socket>, const Address& from);
84
85
85
  Ptr<Socket>     m_socket;       // Associated socket
86
  // In the case of TCP, each socket accept returns a new socket, so the 
87
  // listening socket is stored seperately from the accepted sockets
88
  Ptr<Socket>     m_socket;       // Listening socket
89
  std::list<Ptr<Socket> > m_socketList; //the accepted sockets
90
86
  Address         m_local;        // Local address to bind to
91
  Address         m_local;        // Local address to bind to
87
  TypeId          m_tid;          // Protocol TypeId
92
  TypeId          m_tid;          // Protocol TypeId
88
  TracedCallback<Ptr<const Packet>, const Address &> m_rxTrace;
93
  TracedCallback<Ptr<const Packet>, const Address &> m_rxTrace;

Return to bug 244