Nmap Development mailing list archives
Re: Bug/Enhancement (ncat/nsock) - Recognize Winsock error codes
From: David Fifield <david () bamsoftware com>
Date: Thu, 19 Nov 2009 08:29:53 -0700
On Thu, Nov 19, 2009 at 11:33:24AM +0000, Paul Milliken wrote:
I've noticed that ncat doesn't interpret Windows Socket errors, instead displaying them as "Unknown error". Contrast the following outputs from Windows and Linux respectively: C:\tools\nmap-5.00>ncat -v -v -v 10.10.130.140 8888 Ncat version 5.00 ( http://nmap.org/ncat ) NSOCK (0.0620s) TCP connection requested to 10.10.130.140:8888 (IOD #1) EID 8 NSOCK (1.0160s) Callback: CONNECT ERROR [Unknown error (10061)] for EID 8 [10.10.130.140:8888] DEBUG: Received callback of type CONNECT with status ERROR [paul.milliken@balamb ~]$ ncat -v -v -v 10.10.130.140 8888 Ncat version 5.00 ( http://nmap.org/ncat ) NSOCK (0.0020s) TCP connection requested to 10.10.130.140:8888 (IOD #1) EID 8 NSOCK (0.0020s) Callback: CONNECT ERROR [Connection refused (111)] for EID 8 [10.10.130.140:8888] DEBUG: Received callback of type CONNECT with status ERROR Connection refused. According to MSDN, error code 10061 does indicate connection refused. It would more convenient if ncat interpreted the errors on Windows, especially when attempting to use it to diagnose connection issues.
Hi Paul, thanks for your suggestion. The next release of Ncat will have this. When Ncat has a connection error, it will print the error even without -v, and it will interpret the Windows error codes. The Nsock messages don't interpret the Windows codes, because as I recall those strings can be long and contain newlines. Nsock tracing is a low-level option; we wanted to make the information from common connection errors visible without excessive verbosity. For other developers, when you want to print an error string, use the socket_strerror function from nbase. The normal strerror function on Windows doesn't interpret WinSock error codes. Windows also keeps its error codes separate from the global errno, so you should use the socket_errno function, also from nbase, to get it. socket_strerror(socket_errno()) David Fifield _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://seclists.org/nmap-dev/
Current thread:
- Bug/Enhancement (ncat/nsock) - Recognize Winsock error codes Paul Milliken (Nov 19)
- Re: Bug/Enhancement (ncat/nsock) - Recognize Winsock error codes David Fifield (Nov 19)