Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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; }

hth!


Comment on Re: socket lost by buffer overflow
Download Code
Re^2: socket lost by buffer overflow
by jfroebe (Vicar) 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://416657]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-10-02 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (49 votes), past polls