# HG changeset patch # User Bill Roome # Date 1266817345 28800 # Node ID 59ad62377fcfb790e526589ee1f335b1b98ede8c # Parent 8c16f9fbcc45cf98d474773b80236ee44f678acd [bug 810] Tcp GetSockName() for unconnected sockets diff -r 8c16f9fbcc45 -r 59ad62377fcf src/internet-stack/tcp-socket-impl.cc --- a/src/internet-stack/tcp-socket-impl.cc Fri Feb 19 17:11:16 2010 -0800 +++ b/src/internet-stack/tcp-socket-impl.cc Sun Feb 21 21:42:25 2010 -0800 @@ -630,8 +630,17 @@ TcpSocketImpl::GetSockName (Address &address) const { NS_LOG_FUNCTION_NOARGS (); - address = InetSocketAddress(m_endPoint->GetLocalAddress (), - m_endPoint->GetLocalPort ()); + if (m_endPoint != 0) + { + address = InetSocketAddress (m_endPoint->GetLocalAddress (), + m_endPoint->GetLocalPort ()); + } + else + { + // It is possible to call this method on a socket without a name + // in which case, behavior is unspecified + address = InetSocketAddress (Ipv4Address::GetZero (), 0); + } return 0; } diff -r 8c16f9fbcc45 -r 59ad62377fcf src/internet-stack/udp-socket-impl.cc --- a/src/internet-stack/udp-socket-impl.cc Fri Feb 19 17:11:16 2010 -0800 +++ b/src/internet-stack/udp-socket-impl.cc Sun Feb 21 21:42:25 2010 -0800 @@ -531,6 +531,8 @@ } else { + // It is possible to call this method on a socket without a name + // in which case, behavior is unspecified address = InetSocketAddress(Ipv4Address::GetZero(), 0); } return 0;