diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2017-08-28 02:06:41 +1000 |
---|---|---|
committer | Chris Sherlock <chris.sherlock79@gmail.com> | 2017-08-27 19:38:39 +0200 |
commit | 3d5be8cd31bcf6fce8772133298d2ae076361362 (patch) | |
tree | f06b65976f5f6d9fa1cd98a9d66ccdeb2dcde005 /sal/osl/w32 | |
parent | bbf3da220e8c031022098a4414fd367c39e228c5 (diff) |
osl: give warning on socket error (win32), move Flag definition (unx)
Change-Id: I34b773f32a055dfe85ec9c42e72a9f51ee8fea10
Reviewed-on: https://gerrit.libreoffice.org/41610
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
Tested-by: Chris Sherlock <chris.sherlock79@gmail.com>
Diffstat (limited to 'sal/osl/w32')
-rw-r--r-- | sal/osl/w32/socket.cxx | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/sal/osl/w32/socket.cxx b/sal/osl/w32/socket.cxx index d1086cbaca4b..70d3b56e7d6b 100644 --- a/sal/osl/w32/socket.cxx +++ b/sal/osl/w32/socket.cxx @@ -771,10 +771,10 @@ oslSocketResult SAL_CALL osl_getDottedInetAddrOfSocketAddr ( return osl_Socket_Ok; } -oslSocket SAL_CALL osl_createSocket ( +oslSocket SAL_CALL osl_createSocket( oslAddrFamily Family, oslSocketType Type, - oslProtocol Protocol) + oslProtocol Protocol) { /* alloc memory */ oslSocket pSocket = osl_createSocketImpl_(0); @@ -783,19 +783,28 @@ oslSocket SAL_CALL osl_createSocket ( return nullptr; /* create socket */ - pSocket->m_Socket= socket(FAMILY_TO_NATIVE(Family), - TYPE_TO_NATIVE(Type), - PROTOCOL_TO_NATIVE(Protocol)); + pSocket->m_Socket = socket(FAMILY_TO_NATIVE(Family), + TYPE_TO_NATIVE(Type), + PROTOCOL_TO_NATIVE(Protocol)); /* creation failed => free memory */ if(pSocket->m_Socket == OSL_INVALID_SOCKET) { + sal_uInt32 nErrno = WSAGetLastError(); + wchar_t *sErr = nullptr; + FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, nErrno, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPWSTR)&sErr, 0, NULL); + SAL_WARN("sal.osl", "socket creation failed: (" << nErrno << ") " << sErr); + LocalFree(sErr); + osl_destroySocketImpl_(pSocket); - pSocket= nullptr; + pSocket = nullptr; } else { - pSocket->m_Flags = 0; + pSocket->m_Flags = 0; } return pSocket; |