Nmap Development mailing list archives
Re: Ncat/Nsock on Windows; non-socket select()s
From: doug () hcsw org
Date: Tue, 5 Aug 2008 12:18:50 -0700
On Tue, Aug 05, 2008 at 01:40:27PM -0500 or thereabouts, Kris Katterjohn wrote:
The main problem getting Ncat to work is that Windows' select() doesn't work for non-socket descriptors (i.e. stdin). This presents a problem in Ncat itself and Nsock.
Yes, this is a problem when writing win32 code: You can't use file descriptors in place of sockets or vice-versa. This affects things like select() and fdopen(). Although I've never done this before, one way to do it might be to open a socket, then spawn a thread that basically does this: while(1) { data = read_data_from_stdin(); if (is_stdin_eof()) { close_the_socket(); join_this_thread(); } write_data_to_the_socket(data); } and then use select on the socket as usual in your main thread. This isn't as crazy as it might sound because windows programmers use threads for everything. (I think we could also use this hack to get select()able pcap descriptors on win32) Alternatively, win32 does have some async APIs like WaitForMultipleObjects() which you mentioned. There's also IO Completion Ports: http://msdn.microsoft.com/en-us/library/ms810436.aspx "WaitForMultipleObjects may indeed provide an alternative to I/O completion ports. However, I/O completion ports are much more flexible and easier to use than WaitForMultipleObjects." "An IOCP is an object that can be associated with a number of I/O objects, such as files, named pipes, or sockets. When a thread requests input via the IOCP, the I/O system blocks the calling thread until any pending asynchronous I/O on any of the objects has completed." Doug
Attachment:
signature.asc
Description: Digital signature
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- Ncat/Nsock on Windows; non-socket select()s Kris Katterjohn (Aug 05)
- Re: Ncat/Nsock on Windows; non-socket select()s doug (Aug 05)