Bugzilla – Bug 1201
UDP sockets need to set connected state before notifying the ConnectionSucceeded callback
Last modified: 2011-06-28 14:14:35 UTC
Steve Marotta suggested this fix on the ns-users list here: http://groups.google.com/group/ns-3-users/browse_thread/thread/456d72d7c38ae2a0 diff -r b5c7eb57d8d6 src/internet/model/udp-socket-impl.cc --- a/src/internet/model/udp-socket-impl.cc Fri Jun 24 16:08:55 2011 +0100 +++ b/src/internet/model/udp-socket-impl.cc Mon Jun 27 23:10:36 2011 -0700 @@ -231,8 +231,8 @@ InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); m_defaultAddress = transport.GetIpv4 (); m_defaultPort = transport.GetPort (); + m_connected = true; NotifyConnectionSucceeded (); - m_connected = true; return 0; }
I don't see any drawbacks and any reason we shouldn't do it. After all if the user will check the connection state right in the Notify (kinda stupid imho, but they could), they'd find it not yet connected. So for consistency it seems quite reasonable. +1
fixed: changeset 21678ba057ef
(In reply to comment #1) > I don't see any drawbacks and any reason we shouldn't do it. After all if the > user will check the connection state right in the Notify (kinda stupid imho, > but they could), they'd find it not yet connected. > > So for consistency it seems quite reasonable. > > +1 It's not just for consistency. If you try to send data on a Socket whose m_connected is false, it doesn't work.