Bug 1024 - SetConnectCallback is not called when connection failed?
SetConnectCallback is not called when connection failed?
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: internet
ns-3.9
All Linux
: P5 normal
Assigned To: Adrian S.-W. Tam
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-11-08 22:30 UTC by susie
Modified: 2011-09-29 13:10 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description susie 2010-11-08 22:30:53 UTC
I'm writing a BitTorrent application, but I find the callback SetConnectCallback's connectionFailed function is not called when the destination address and port doesn't exist.  I try to use the return value if Connect function to decide whether connection success, but it doesn't work.
 My code is:

Ptr<Socket> peer_socket = Socket::CreateSocket (local,TcpSocketFactory::GetTypeId ());
peer_socket->Connect(InetSocketAddress( remotePeer->m_ip, remotePeer->m_port ));
peer_socket->SetConnectCallback(MakeCallback(&Peer::PeerConnectionSucceeded,this) , MakeCallback(&Peer::PeerConnectionFailed, this));

And I read ns-3.9/src/internet-stack/tcp-socket-impl.cc , I find 
 bool TcpSocketImpl::ProcessAction (Actions_t a)
  case APP_NOTIFY:
      NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action APP_NOTIFY");
      break;


Does tcp-socket-impl.cc do nothing when connect failed ?
or is there something wrong with my code?

Thanks for your help!
Comment 1 susie 2010-11-08 22:54:03 UTC
Then I add  " NotifyConnectionFailed (); "  to the function ,then it seems correct.
    case APP_NOTIFY:
      NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action APP_NOTIFY");
      NotifyConnectionFailed (); //added by susie
      break;


Shall I do this?
Comment 2 Tom Henderson 2011-08-09 15:10:31 UTC
Need to confirm this is still a bug.
Comment 3 Adrian S.-W. Tam 2011-09-29 13:10:33 UTC
The original bug report was spotting the fact that TcpSocketImpl did not call the Callback function upon failure. This is no longer valid in the TcpSocketBase implementation, and the callback is invoked in TcpSocketBase::DoRetransmit() when connection retries are used up. Thus this bug is closed.