Re: unexpected behavior with GIOChannels?



nega exmachinae net wrote:

If I connect that to something like netcat (nc -l $host -p $port),
then kill netcat, I'd expect a HUP since the socket is broken. Instead
i get an endless loop of:

$VAR1 = \[
            'in'
          ];

Which seems odd since if there's no socket, how can there be data
waiting to be read?

Simply check eof($sock) in your input handler (before reading from 
$sock) to check whether the pipe is broken or it is safe to read a line.

Probably take a look at Gtk2::Helper. It implements convenience 
functions regarding IO monitoring and has example code in the manpage.

Regards,

Joern

Attachment: pgpK4i9ikPrdX.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]