in reply to Re: Problem Keeping Socket Alive
in thread Problem Keeping Socket Alive

This program is logging phone calls in real time over ethernet, so I could be waiting from 1 sec to 5 hours for more output on the socket, depending on whether anybody calls or not. I will lower the timeout, though. Maybe I'll try 7200sec (2 hours)

I explained the problem poorly - the script doesn't actually "die" - it's still running, just not logging the output anymore, and if I try to telnet to my device at the port that my script is supposed to be listening to, I am refused - so I know the socket is still open.

Replies are listed 'Best First'.
Re: Re: Re: Problem Keeping Socket Alive
by waswas-fng (Curate) on Dec 23, 2002 at 18:02 UTC
    What does netstat show the state of the conn being when this error state happens? Also do you have control of the sending side of this? if so, it might make sense to do a heartbeat (a dummy packet that gets discarded in the scope of the log) every few minutes that forces all firewalls etc between the two hosts to think that the connection is active over long periods of inactivity.

    Edited:
    Also, getline is fine. And since you don't need this to timeout at all, you can use undef for the timeout value to turn off timeouts completely.

    -Waswas
      Unfortunatly, I do not have control over the remote device. The socket is connected to a remote device server called a UDS-10 by Lantronix, this device is like an Ethernet to Serial brige, buffering output from a connected serial device (in this case a phone switch) and allowing me to collect the output over TCP/IP from port 10001 - but if I send it any data, it will disable logging on the phone switch, and I will have to turn it on again in their software. The phone switch itself is supposed to be connected to a serial printer, but I just connect it to this device, parse the data, and drop it into an Informix database.

      Do you think maybe the problem is in the $line = $socket->getline; statement? Should I be using $line = <$socket>; instead?
        Just two more questions and I think I can narrow it down, 1, is there any firewall device between the UDS-10 and the logging server? (if yes brand) 2, could you get me a output of netstat for the port when it is in error state? Thanks.

        -Waswas