mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-24 17:41:34 +08:00
Unhandled errors
inet_aton(), InetPton() return codes
This commit is contained in:
parent
99fda0ed22
commit
14eecc6e2a
@ -64,7 +64,11 @@ public:
|
||||
addr_.sin_family = PF_INET;
|
||||
addr_.sin_port = htons(port);
|
||||
addr_.sin_addr.s_addr = INADDR_ANY;
|
||||
InetPton(PF_INET, TEXT(host.c_str()), &addr_.sin_addr.s_addr);
|
||||
if (InetPton(PF_INET, TEXT(host.c_str()), &addr_.sin_addr.s_addr) != 1) {
|
||||
int last_error = ::WSAGetLastError();
|
||||
::WSACleanup();
|
||||
throw_winsock_error_("error: Invalid address!", last_error);
|
||||
}
|
||||
|
||||
socket_ = ::socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (socket_ == INVALID_SOCKET)
|
||||
|
@ -58,7 +58,11 @@ public:
|
||||
|
||||
sockAddr_.sin_family = AF_INET;
|
||||
sockAddr_.sin_port = htons(port);
|
||||
::inet_aton(host.c_str(), &sockAddr_.sin_addr);
|
||||
|
||||
if (::inet_aton(host.c_str(), &sockAddr_.sin_addr) == 0) {
|
||||
cleanup_();
|
||||
throw_spdlog_ex("error: Invalid address!");
|
||||
}
|
||||
|
||||
::memset(sockAddr_.sin_zero, 0x00, sizeof(sockAddr_.sin_zero));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user