[bug 810] Tcp GetSockName() for unconnected sockets

This commit is contained in:
Bill Roome
2010-03-01 15:43:00 -05:00
parent 80e76b0ac6
commit 5f1eb84b33
2 changed files with 13 additions and 2 deletions

View File

@@ -630,8 +630,17 @@ int
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;
}

View File

@@ -531,6 +531,8 @@ UdpSocketImpl::GetSockName (Address &address) const
}
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;