Bugzilla – Bug 1024
SetConnectCallback is not called when connection failed?
Last modified: 2011-09-29 13:10:33 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!
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?
Need to confirm this is still a bug.
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.