Bug 1164 - IPV4 TCP Bind an already used port failed but without setting errno
authorJohn Abraham <john.abraham@gatech.edu>
Wed, 17 Aug 2011 11:39:16 -0400
changeset 7440 979d65377d5f
parent 7439 f68e823f5315
child 7441 bf446d9feecc
Bug 1164 - IPV4 TCP Bind an already used port failed but without setting errno
src/internet/model/tcp-socket-base.cc
src/network/model/socket.h
--- a/src/internet/model/tcp-socket-base.cc	Tue Aug 16 21:44:36 2011 -0700
+++ b/src/internet/model/tcp-socket-base.cc	Wed Aug 17 11:39:16 2011 -0400
@@ -242,6 +242,11 @@
   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 @@
   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);
 
--- a/src/network/model/socket.h	Tue Aug 16 21:44:36 2011 -0700
+++ b/src/network/model/socket.h	Wed Aug 17 11:39:16 2011 -0400
@@ -82,6 +82,7 @@
     ERROR_NOROUTETOHOST,
     ERROR_NODEV,
     ERROR_ADDRNOTAVAIL,
+    ERROR_ADDRINUSE,
     SOCKET_ERRNO_LAST
   };