
Nmap Development mailing list archives
Re: Options to replace select in Nsock
From: Michael Pattrick <mpattrick () rhinovirus org>
Date: Sat, 20 Jun 2009 20:07:20 -0400
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. 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
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)