diff options
Diffstat (limited to 'comm')
-rw-r--r-- | comm/Socket.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/comm/Socket.cc b/comm/Socket.cc index 61244fa..fc6f777 100644 --- a/comm/Socket.cc +++ b/comm/Socket.cc @@ -147,12 +147,15 @@ IvlSocket :: Bind (IvlAddress* addr) int ret = bind (Fd, BAddr->GetSockAddr (), BAddr->Length ()); if (ret < 0) return ret; - + + /* retrieve actual address that was allocated. This is useful if + ANYADDR was passed and we need to know the port number */ GEN_ADDR naddr; socklen_t alen = sizeof (naddr); if (getsockname (Fd, &naddr.sa, &alen) < 0) return -1; BindTo (IvlAddress::Decode (&naddr, alen)); + return ret; } @@ -175,12 +178,15 @@ IvlSocket :: Connect (IvlAddress* addr) int ret = connect (Fd, CAddr->GetSockAddr (), CAddr->Length ()); if (ret < 0) return ret; - + + /* retrieve actual address that was allocated. This is useful if + ANYADDR was passed and we need to know the port number */ GEN_ADDR naddr; socklen_t alen = sizeof (naddr); if (getpeername (Fd, &naddr.sa, &alen) < 0) return -1; ConnectTo (IvlAddress::Decode (&naddr, alen)); + return ret; } |