net-connect timeout

Q&A's, tips, howto's
Locked
kanen
Posts: 145
Joined: Thu Mar 25, 2010 6:24 pm
Contact:

net-connect timeout

Post by kanen »

Searched, but couldn't find an answer. I am not the most patient forum searcher, tho...

Is there a way to specify a net-connect timeout value so I do not spend too long trying to connect to a port that is not open or a system that is not online?

The default value, whatever it is, is too long for what I am doing and I need a shorter timeout.
. Kanen Flowers http://kanen.me .

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: net-connect timeout

Post by Lutz »

The C socket API, on which the newLISP net-xxx API is based, does not offer to set a timeout fosocket connection call. On UNIX this timeout is a kernel setting. On Mac OS X and other BSDs, you could use the sysctl shell utility to change this setting, and you could do that from inside newLISP using (exec "sysctl ...") with the appropiate ... specification.

kanen
Posts: 145
Joined: Thu Mar 25, 2010 6:24 pm
Contact:

Re: net-connect timeout

Post by kanen »

I get the impression this conversation sounds familiar to you. Didn't we have this exact same conversation at kozoru? :)

I suppose I am going to write a packet library for newLISP, then. As I need to be able to construct packets of arbitrary timeouts and with arbitrary header and payloads.

Has anyone written a libnet newLISP wrapper yet? If so, I would love to play with it.
Lutz wrote:The C socket API, on which the newLISP net-xxx API is based, does not offer to set a timeout fosocket connection call. On UNIX this timeout is a kernel setting. On Mac OS X and other BSDs, you could use the sysctl shell utility to change this setting, and you could do that from inside newLISP using (exec "sysctl ...") with the appropiate ... specification.
. Kanen Flowers http://kanen.me .

kanen
Posts: 145
Joined: Thu Mar 25, 2010 6:24 pm
Contact:

Re: net-connect timeout

Post by kanen »

This, as you know, irritates me.

So, I wrote a port-knocking program (in C) which should compile on any version of Linux/BSD/Windows, assuming you have a C compiler installed. It constructs a packet and connects to ports (like a port scanner), but it is so much faster than doing a net-connect.

Anyway, the .so imports into newLISP perfectly (of course) and I will post the code and examples here and/or my blog soon.

P.S. Loving newLISP again.
Lutz wrote:The C socket API, on which the newLISP net-xxx API is based, does not offer to set a timeout fosocket connection call. On UNIX this timeout is a kernel setting. On Mac OS X and other BSDs, you could use the sysctl shell utility to change this setting, and you could do that from inside newLISP using (exec "sysctl ...") with the appropiate ... specification.
. Kanen Flowers http://kanen.me .

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: net-connect timeout

Post by Lutz »

A few years back, I experimented with raw sockets trying to write a 'net-packet' function, but could not get it too work, even the pure C examples. I am definitely interested in the C code!

kanen
Posts: 145
Joined: Thu Mar 25, 2010 6:24 pm
Contact:

Re: net-connect timeout

Post by kanen »

Code and examples in newLISP posted: http://www.lifezero.org - under the title "port-knock'n"

Next up, a RAW Packet Creation library for newLISP. :)
. Kanen Flowers http://kanen.me .

Locked