Nmap Development mailing list archives
Re: A sleep function for NSE
From: David Fifield <david () bamsoftware com>
Date: Fri, 20 Feb 2009 11:55:40 -0700
On Wed, Feb 18, 2009 at 10:07:15PM +0000, jah wrote:
On 18/02/2009 20:24, David Fifield wrote:Does someone else have a use for a sleep function? Is the design suitable for you?sleep() looks good. I wonder whether t should take milliseconds as other operations do - socket.set_timeout for example. I guess it largely depends on how long scripts generally want to sleep a coroutine for - just a thought.
Thanks for bringing that up. In high-level languages I prefer times to be always in seconds, but consistency with other parts of the library is more important than that. I found nmap.clock_ms and nmap.set_timeout that take times in milliseconds. msrpctypes.lua converts times to seconds even when the protocol uses some other representation. grepping for "seconds" didn't find anything else relevant. http://nmap.org/nsedoc/modules/nmap.html#clock_ms http://nmap.org/nsedoc/modules/nmap.html#set_timeout http://nmap.org/nsedoc/modules/msrpctypes.html#marshall_NTTIME A function called "sleep" normally takes an argument in seconds, even if it only provides integer precision. So if the function changes to take milliseconds its name has to change too. In the name of consistency, I think there are only two choices: sleep taking a floating-point number of seconds, or sleep_ms taking an integer number of milliseconds. My preference would be to have sleep take floating-point seconds, and to change nmap.clock_ms and nmap.set_timeout to deal in seconds also. The settimeout in Python does it in seconds: http://docs.python.org/library/socket.html#socket.socket.settimeout Furthermore, clock_ms should be renamed "time" because it is more like the time function in C or os.time in Lua (seconds since 1970) than it is the C clock function (time since some arbitrary point in arbitrary units). clock_ms is doubly frustrating because it uses gettimeofday, which provides microsecond precision, then purposely degrades the result to return milliseconds. It may be too late for nmap.set_timeout because that would be an incompatible change. nmap.clock_ms is easier because it is currently hardly used and its name should change anyway. Any thoughts? David Fifield _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- A sleep function for NSE David Fifield (Feb 18)
- Re: A sleep function for NSE Ron (Feb 18)
- Re: A sleep function for NSE David Fifield (Feb 18)
- Re: A sleep function for NSE Ron (Feb 18)
- Re: A sleep function for NSE David Fifield (Feb 18)
- Re: A sleep function for NSE jah (Feb 18)
- Re: A sleep function for NSE Arturo 'Buanzo' Busleiman (Feb 18)
- Re: A sleep function for NSE David Fifield (Feb 20)
- Re: A sleep function for NSE Ron (Feb 20)
- Re: A sleep function for NSE jah (Feb 20)
- Re: A sleep function for NSE David Fifield (Feb 20)
- Re: A sleep function for NSE Ron (Feb 18)
- Re: A sleep function for NSE David Fifield (Feb 23)