mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 06:40:48 +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:
parent
19c2d93903
commit
577fc127f7
1 changed files with 10 additions and 2 deletions
12
tcpip.cc
12
tcpip.cc
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue