diff options
author | B Stack <bgstack15@gmail.com> | 2020-04-18 17:00:42 +0000 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2020-04-18 17:00:42 +0000 |
commit | b4ecf755bad016b0d7fbb277106887f405f6b600 (patch) | |
tree | 8cfcea5441be72ad92095a3887ded84d38f9ba11 /zen/socket.h | |
parent | Merge branch '10.22' into 'master' (diff) | |
parent | add upstream 10.23 (diff) | |
download | FreeFileSync-b4ecf755bad016b0d7fbb277106887f405f6b600.tar.gz FreeFileSync-b4ecf755bad016b0d7fbb277106887f405f6b600.tar.bz2 FreeFileSync-b4ecf755bad016b0d7fbb277106887f405f6b600.zip |
Merge branch '10.23' into 'master'10.23
add upstream 10.23
See merge request opensource-tracking/FreeFileSync!20
Diffstat (limited to 'zen/socket.h')
-rw-r--r-- | zen/socket.h | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/zen/socket.h b/zen/socket.h index 3bd0a2a0..f1d26450 100644 --- a/zen/socket.h +++ b/zen/socket.h @@ -42,19 +42,19 @@ public: const int rcGai = ::getaddrinfo(server.c_str(), serviceName.c_str(), &hints, &servinfo); if (rcGai != 0) - throw SysError(formatSystemError(L"getaddrinfo", replaceCpy(_("Error Code %x"), L"%x", numberTo<std::wstring>(rcGai)), utfTo<std::wstring>(::gai_strerror(rcGai)))); + throw SysError(formatSystemError("getaddrinfo", replaceCpy(_("Error code %x"), L"%x", numberTo<std::wstring>(rcGai)), utfTo<std::wstring>(::gai_strerror(rcGai)))); if (!servinfo) - throw SysError(L"getaddrinfo: empty server info"); + throw SysError(formatSystemError("getaddrinfo", L"", L"Empty server info.")); const auto getConnectedSocket = [](const auto& /*::addrinfo*/ ai) { SocketType testSocket = ::socket(ai.ai_family, ai.ai_socktype, ai.ai_protocol); if (testSocket == invalidSocket) - THROW_LAST_SYS_ERROR_WSA(L"socket"); + THROW_LAST_SYS_ERROR_WSA("socket"); ZEN_ON_SCOPE_FAIL(closeSocket(testSocket)); if (::connect(testSocket, ai.ai_addr, static_cast<int>(ai.ai_addrlen)) != 0) - THROW_LAST_SYS_ERROR_WSA(L"connect"); + THROW_LAST_SYS_ERROR_WSA("connect"); return testSocket; }; @@ -102,10 +102,10 @@ size_t tryReadSocket(SocketType socket, void* buffer, size_t bytesToRead) //thro break; } if (bytesReceived < 0) - THROW_LAST_SYS_ERROR_WSA(L"recv"); + THROW_LAST_SYS_ERROR_WSA("recv"); if (static_cast<size_t>(bytesReceived) > bytesToRead) //better safe than sorry - throw SysError(L"recv: buffer overflow."); + throw SysError(formatSystemError("recv", L"", L"Buffer overflow.")); return bytesReceived; //"zero indicates end of file" } @@ -127,11 +127,11 @@ size_t tryWriteSocket(SocketType socket, const void* buffer, size_t bytesToWrite break; } if (bytesWritten < 0) - THROW_LAST_SYS_ERROR_WSA(L"send"); + THROW_LAST_SYS_ERROR_WSA("send"); if (bytesWritten > static_cast<int>(bytesToWrite)) - throw SysError(L"send: buffer overflow."); + throw SysError(formatSystemError("send", L"", L"Buffer overflow.")); if (bytesWritten == 0) - throw SysError(L"send: zero bytes processed"); + throw SysError(formatSystemError("send", L"", L"Zero bytes processed.")); return bytesWritten; } @@ -143,7 +143,7 @@ inline void shutdownSocketSend(SocketType socket) //throw SysError { if (::shutdown(socket, SHUT_WR) != 0) - THROW_LAST_SYS_ERROR_WSA(L"shutdown"); + THROW_LAST_SYS_ERROR_WSA("shutdown"); } } |