Fareway
Dec 23 2003, 01:01 PM
can someone tell me why the option -w in netcat doesn't work?
-w secs timeout for connects and final net reads
eg: netcat -w 2 128.158.1.5 5000
I think if netcat can't get a connection to this host it gives up after 2 sec. But it doesn't give up trying to connect. Am i wrong or does the -w option mean something else?
agamemnon
Dec 24 2003, 12:30 AM
Hmmm, my impression is that the '-w #' would let netcat connect as normal, but then only for the time specified in #.
That is to say that, "nc 127.0.0.1 -p 6 -w 3" would connect to localhost on port 6 for three seconds, at which point it would disconnect...
I'm not so sure as it was designed to be used as a 'give up' disconnection method - though I've never tried...
-ed.
Blast3rPL
Dec 24 2003, 06:34 PM
As I know it's a parametr that provides a timeout value for each connection. If you scan for open ports or want to connect use it for value timeout. But I hadnn't tested is parametr work when I want to download or upload any file.
I've tested it with port scanning and it's working all fine
Fareway
Dec 25 2003, 06:47 AM
thx folks, i think i'll code my little timeout routine by myself.
ara2
Jan 6 2004, 11:11 PM
| QUOTE |
-w # => Timeout after # seconds
Note that -w also sets the network inactivity timeout. This does not have any effect until standard input closes, but then if nothing further arrives from the network in the next <timeout> seconds, netcat tries to read the net once more for good measure, and then closes and exits. There are a lot of network services now that accept a small amount of input and return a large amount of output, such as Gopher and Web servers, which is the main reason netcat was written to ``block'' on the network staying open rather than standard input. Handling the timeout this way gives uniform behavior with network servers that *don't* close by themselves until told to.
This works for final net reads but not for connections. |
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.