]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
winverbs.dll: retrieve socket information after binding
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 20 Jan 2009 07:57:01 +0000 (07:57 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 20 Jan 2009 07:57:01 +0000 (07:57 +0000)
bind() does not return a socket's address and port number as output.  Call getsockname() to return the obtained port number.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1@1852 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

branches/winverbs/core/winverbs/user/wv_ep.cpp

index 6d7fec67d536949d3cdc278af31227c22dacf500..ddf646709c9d5a695b49e388114c9c762f8e03ff 100644 (file)
@@ -164,6 +164,7 @@ BindAddress(SOCKADDR* pAddress)
        WV_IO_EP_BIND           attr;\r
        BOOLEAN                         any;\r
        DWORD                           bytes;\r
+       int                                     len;\r
        HRESULT                         hr;\r
 \r
        if (pAddress->sa_family == AF_INET) {\r
@@ -190,11 +191,15 @@ BindAddress(SOCKADDR* pAddress)
 \r
        hr = bind(m_Socket, pAddress, bytes);\r
        if (FAILED(hr)) {\r
-               goto err;\r
+               goto get_err;\r
        }\r
 \r
        attr.Id = m_Id;\r
-       RtlCopyMemory(&attr.Address, pAddress, bytes);\r
+       len = sizeof attr.Address;\r
+       hr = getsockname(m_Socket, (sockaddr *) &attr.Address, &len);\r
+       if (FAILED(hr)) {\r
+               goto get_err;\r
+       }\r
 \r
        if (!WvDeviceIoControl(m_hFile, WV_IOCTL_EP_BIND, &attr, sizeof attr,\r
                                                   &attr, sizeof attr, &bytes, NULL)) {\r
@@ -204,6 +209,8 @@ BindAddress(SOCKADDR* pAddress)
 \r
        return WV_SUCCESS;\r
 \r
+get_err:\r
+       hr = WSAGetLastError();\r
 err:\r
        closesocket(m_Socket);\r
        m_Socket = INVALID_SOCKET;\r