[aprssig] Perl APRS IS

Heikki Hannikainen hessu at hes.iki.fi
Tue Sep 22 03:56:01 EDT 2009


On Tue, 22 Sep 2009, Andrew Rich wrote:

> 3. The script will start, and then run but stay up - ie the telnet
> connection has gone stale

As a sidenote, if you're connecting to an APRS-IS server, it's not 
actually a telnet connection (the telnet protocol is not used at all). 
It's just a plain TCP connection.

> I am now looking at coding something based on the time and date of the
> APRS IS heartbeat every 40 seconds.
>  
> Ideas on how to manage stale connections ?
>  
> PERL does not seem to die on a stale connection - that is my issue

That's not a fault of Perl, or any other language.

The application could maybe send some data on the connection every now and 
then (like a timestamp packet with a # in the beginning, much like what 
you get from the APRS-IS server), so that the operating system's TCP stack 
will figure out that the data does not get through, and the connection 
needs to be closed. There's no way for the OS TCP stack to figure if (1) 
the other end has nothing to send, or (2) if the other end is sending 
something but it's not getting through.

The other alternative is making the application figure out that there's 
nothing coming in for a certain time. Every time you get something, look 
up the current time ($last_received = time();). Then, use non-blocking IO 
on the TCP socket, and use the select() system call with a timeout. When 
the select() returns and doesn't indicate that there would be anything to 
receive on the socket, check if too much time has passed since the last 
received complete packet, and consider closing the connection.

These instructions work for other programming languages, too.

   - Hessu


More information about the aprssig mailing list