1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Use socket_strerror, not plain strerror, to report the result of non-blocking

connections in tcpip.cc. socket_strerror works with Winsock error codes whereas
plain strerror returns "Unknown error".

However, the error string for what is probably the most common error code,
WSAEWOULDBLOCK, is the big ugly "A non-blocking socket operation could not be
completed immediately.". Add a special case to use "Operation now in progress"
for that specific error.
This commit is contained in:
david
2010-01-13 19:22:41 +00:00
parent 19c2d93903
commit 577fc127f7

View File

@@ -825,10 +825,18 @@ void PacketTrace::traceConnect(u8 proto, const struct sockaddr *sock,
assert(proto == IPPROTO_TCP || proto == IPPROTO_UDP);
if (connectrc == 0)
if (connectrc == 0) {
Strncpy(errbuf, "Connected", sizeof(errbuf));
}
#if WIN32
else if (connect_errno == WSAEWOULDBLOCK) {
/* Special case for WSAEWOULDBLOCK. socket_strerror returns the unwieldy
"A non-blocking socket operation could not be completed immediately." */
Strncpy(errbuf, "Operation now in progress", sizeof(errbuf));
}
#endif
else {
Snprintf(errbuf, sizeof(errbuf), "%s", strerror(connect_errno));
Snprintf(errbuf, sizeof(errbuf), "%s", socket_strerror(connect_errno));
}
if (sin->sin_family == AF_INET) {