Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: socket lost by buffer overflow

by elwarren (Curate)
on Dec 22, 2004 at 00:07 UTC ( #416657=note: print w/replies, xml ) Need Help??

in reply to socket lost by buffer overflow

You should check the return of the print to your socket for undef. This means the other end of the connection is gone. You don't have any code, so this is just my assumption. Change your code to do something like this:
my $sockstatus; while (<YOURLOOP>) { $sockstatus = print $socket $data; last unless $sockstatus; }


Replies are listed 'Best First'.
Re^2: socket lost by buffer overflow
by jfroebe (Parson) on Dec 22, 2004 at 06:37 UTC

    Hi :-)

    Dug's method will handle when the os notifies us when the tcp keepalive mechanism determines that the client is no longer there if the client doesn't close the tcp connection itself.

    elwarren's method will proactively perform a 'ping' to the client to determine if the client is no longer there.

    Which to use? Depends if you when you need to know when a client connection disappears. Do you really need to know if it disappears within 10 seconds?

    IMHO, a connectionless (udp based) would be preferrable. There is a simple example in the Perl Cookbook IIRC.

    Jason L. Froebe

    Team Sybase member

    No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

      The problems seal3 is seeing is on writing to a socket, not reading from it. I just posted the simplest solution.

      seal3 can you show us your code?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://416657]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2017-11-24 09:47 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (346 votes). Check out past polls.