in reply to How time out can be done here?

my $bits = ""; vec($bits,fileno(MySocket),1)=1; select($bits,undef,undef,3); if(vec($bits,fileno(MySocket),1)){ $MySocket->recv($text,1000) } else{ die("Time out!\n"); }

Replies are listed 'Best First'.
Re^2: How time out can be done here?
by sanjay nayak (Sexton) on Oct 10, 2006 at 04:03 UTC
    Hi
    Thanks a lot for the code. But can you briefly explain me the code.
    Regd's
    Sanjay nayak.

      There's really nothing to explain. It does exactly what you asked for by calling select RBITS,WBITS,EBITS,TIMEOUT.

      Note that IO::Select is easier to use than select.

      use IO::Select (); my $sel = IO::Select->new($MySocket); my @read = $sel->can_read(3) or die("Time out!\n"); $MySocket->recv($text);
Re^2: How time out can be done here?
by sanjay nayak (Sexton) on Oct 09, 2006 at 13:47 UTC
    Hi
    Thanks a lot.
    Regd's
    Sanjay Nayak