Bug 1164 - IPV4 TCP Bind an already used port failed but without setting errno

This commit is contained in:
John Abraham
2011-08-17 11:39:16 -04:00
parent 2c748ecc31
commit 2c0e7f05ef
2 changed files with 11 additions and 0 deletions

View File

@@ -242,6 +242,11 @@ TcpSocketBase::Bind (const Address &address)
else if (ipv4 == Ipv4Address::GetAny () && port != 0)
{
m_endPoint = m_tcp->Allocate (port);
if (0 == m_endPoint)
{
m_errno = ERROR_ADDRINUSE;
return -1;
}
}
else if (ipv4 != Ipv4Address::GetAny () && port == 0)
{
@@ -250,6 +255,11 @@ TcpSocketBase::Bind (const Address &address)
else if (ipv4 != Ipv4Address::GetAny () && port != 0)
{
m_endPoint = m_tcp->Allocate (ipv4, port);
if (0 == m_endPoint)
{
m_errno = ERROR_ADDRINUSE;
return -1;
}
}
NS_LOG_LOGIC ("TcpSocketBase " << this << " got an endpoint: " << m_endPoint);

View File

@@ -82,6 +82,7 @@ public:
ERROR_NOROUTETOHOST,
ERROR_NODEV,
ERROR_ADDRNOTAVAIL,
ERROR_ADDRINUSE,
SOCKET_ERRNO_LAST
};