in reply to Re^2: Using read/syswrite with IO::Socket::SSL
in thread Using read/syswrite with IO::Socket::SSL

A ->can_read(0) does not block, but only do the read if it returns your read filehandle.

  • Comment on Re^3: Using read/syswrite with IO::Socket::SSL

Replies are listed 'Best First'.
Re^4: Using read/syswrite with IO::Socket::SSL
by Bloehdian (Beadle) on Oct 26, 2016 at 17:31 UTC

    O.k., can_read() takes a timeout value as an argument and if that it set to 0, it will not block. I understand.

    According to the docs it returns a list of handles that are ready for reading.

    Is it correct that I have to traverse this list and check whether $sock is amongst them to fulfil the condition You stated?

      ->can_read(0) will only return handles that have been set into the IO::Select object. Only set those you are interested in.

      BTW, from the fragment you gave, $sock is your listen socket and is only used for accepts. $client_sock is your read/write socket.

      typical code fragment:

      for my $handle ( $sel->can_read(0) ) { if( $handle == $sock ) { # do accepts here... } elsif( $handle == $client_sock ) { # do sysreads here... } }