Nmap Development mailing list archives
Re: Options to replace select in Nsock
From: Brandon Enright <bmenrigh () ucsd edu>
Date: Sun, 21 Jun 2009 00:49:47 +0000
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sat, 20 Jun 2009 20:07:20 -0400 Michael Pattrick <mpattrick () rhinovirus org> wrote:
As a side note, the default limit of fd_set in windows is 64 according to [0], Surprising that someone noticed an overflow on Linux before Windows.
Considering Microsoft limited the number of pending connections to 10 until very recently it makes sense that it would be hard to get 64 sockets simultaneously open on Windows. There is a pretty good discussion of Winsock here: http://tangentsoft.net/wskfaq/advanced.html As for your code below, I think David is right in that it wont actually work because although we'd be setting the bits for each file descriptor, select() won't know to treat socket 1025 as socket 1025 and not just socket 1. Brandon
On Sat, Jun 20, 2009 at 7:28 PM, David Fifield<david () bamsoftware com> wrote:In the meantime, couldn't Nsock be quickly adapted to use multiple calls to select with different FD_SET arrays when tracking > FD_SETSIZE items?I don't think you can use select that way. Each fd_set is indexed starting at zero.I was referring to something like this: int numberOfSockets=2000; fd_set *rfds; struct timeval tv; struct timeval dontStop; int action = 0; int i=0, k=0; int selectorCount = ceil(numberOfSockets/FD_SETSIZE); rfds = malloc(selectorCount); for(i=0;i<selectorCount;i++){ FD_ZERO(&rfds[i]); } for(i=0;i<numberOfSockets;i++){ FD_SET(Socket[i], &rfds[floor(i/FD_SETSIZE)]); } /* Wait up to five seconds. */ tv.tv_sec = 5; tv.tv_usec = 0; dontStop.tv_sec = 0; dontStop.tv_usec = 0; while(1){ for(i=0;i<(selectorCount-1);i++){ action = select(1, &rfds[i], NULL, NULL, &dontStop); if(action>0){ actOnDescriptors(rfds[i]) break; } } if(!action){ action = select(1, &rfds[selectorCount-1], NULL, NULL, &tv); if(action){ actOnDescriptors(rfds[selectorCount-1]) } } } [0] http://msdn.microsoft.com/en-us/library/ms740141.aspx _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (GNU/Linux) iEYEARECAAYFAko9g78ACgkQqaGPzAsl94K6lwCgmXqBY8NwSR1tRttn65uMKajN rEkAnjj5y2fdY2tYKERBX1pC7X+UFExJ =SXKs -----END PGP SIGNATURE----- _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- Options to replace select in Nsock David Fifield (Jun 19)
- Re: Options to replace select in Nsock doug (Jun 20)
- Re: Options to replace select in Nsock Michael Pattrick (Jun 20)
- Re: Options to replace select in Nsock David Fifield (Jun 20)
- Re: Options to replace select in Nsock Michael Pattrick (Jun 20)
- Re: Options to replace select in Nsock Brandon Enright (Jun 20)
- Re: Options to replace select in Nsock doug (Jun 20)
- Re: Options to replace select in Nsock Brandon Enright (Jun 20)
- Re: Options to replace select in Nsock Michael Pattrick (Jun 20)
- Re: Options to replace select in Nsock doug (Jun 20)