Refactor OnOff so Start doesn't immediate close the socket (bug 259)
authorRaj Bhattacharjea <raj.b@gatech.edu>
Fri Aug 15 12:58:53 2008 -0400 (18 months ago)
changeset 3551016c70fa60d8
parent 3550 e170f2c17e03
child 3552 087b1b45b3b5
Refactor OnOff so Start doesn't immediate close the socket (bug 259)
src/applications/onoff/onoff-application.cc
src/applications/onoff/onoff-application.h
     1.1 --- a/src/applications/onoff/onoff-application.cc	Fri Aug 15 11:25:18 2008 -0400
     1.2 +++ b/src/applications/onoff/onoff-application.cc	Fri Aug 15 12:58:53 2008 -0400
     1.3 @@ -135,7 +135,7 @@
     1.4        m_socket->Connect (m_peer);
     1.5      }
     1.6    // Insure no pending event
     1.7 -  StopApplication();
     1.8 +  CancelEvents ();
     1.9    // If we are not yet connected, there is nothing to do here
    1.10    // The ConnectionComplete upcall will start timers at that time
    1.11    //if (!m_connected) return;
    1.12 @@ -146,6 +146,14 @@
    1.13  {
    1.14    NS_LOG_FUNCTION_NOARGS ();
    1.15  
    1.16 +  CancelEvents ();
    1.17 +  m_socket->Close ();
    1.18 +}
    1.19 +
    1.20 +void OnOffApplication::CancelEvents ()
    1.21 +{
    1.22 +  NS_LOG_FUNCTION_NOARGS ();
    1.23 +
    1.24    if (m_sendEvent.IsRunning ())
    1.25      { // Cancel the pending send packet event
    1.26        // Calculate residual bits since last packet sent
     2.1 --- a/src/applications/onoff/onoff-application.h	Fri Aug 15 11:25:18 2008 -0400
     2.2 +++ b/src/applications/onoff/onoff-application.h	Fri Aug 15 12:58:53 2008 -0400
     2.3 @@ -83,6 +83,9 @@
     2.4    virtual void StartApplication (void);    // Called at time specified by Start
     2.5    virtual void StopApplication (void);     // Called at time specified by Stop
     2.6  
     2.7 +  //helpers
     2.8 +  void CancelEvents ();
     2.9 +
    2.10    void Construct (Ptr<Node> n,
    2.11                    const Address &remote,
    2.12                    std::string tid,