Probably, the sockets are connected in the following parts.
This source code appears to make a trace connection after the socket is connected, is that different?
Ipv4Address remote = users.Get (1)->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();
BulkSendHelper sender ("ns3::TcpSocketFactory",
InetSocketAddress (remote, port));
// Set the amount of data to send in bytes. Zero is unlimited.
sender.SetAttribute ("MaxBytes", UintegerValue (0));
ApplicationContainer sourceApps = sender.Install (users.Get (0));
sourceApps.Start (Seconds (0.0));
//
// Create a PacketSinkApplication and install it on node 1
//
PacketSinkHelper sink ("ns3::TcpSocketFactory",
InetSocketAddress (Ipv4Address::GetAny (), port));
ApplicationContainer sinkApps = sink.Install (users.Get (1));
sinkApps.Start (Seconds (0.0));
Config::Connect ("/NodeList/*/$ns3::TcpL4Protocol/SocketList/*/Tx",
MakeCallback (&EchoTxRx));
Config::Connect ("/NodeList/*/$ns3::TcpL4Protocol/SocketList/*/Rx",
MakeCallback (&EchoTxRx));
//
// Set up tracing if enabled
//
if (pcap)
{
AsciiTraceHelper ascii;
utCh.EnablePcapAll ("tcp-bulk-send", false);
}
std::cerr << "LOCAL =" << users.Get (0)->GetId () << std::endl;
std::cerr << "REMOTE=" << users.Get (1)->GetId () << ",addr=" << Ipv4Address::ConvertFrom (remote) << std::endl;