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
\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
\r
return WV_SUCCESS;\r
\r
+get_err:\r
+ hr = WSAGetLastError();\r
err:\r
closesocket(m_Socket);\r
m_Socket = INVALID_SOCKET;\r