in reply to sysread()
Here's an example of using select instead to wait three seconds for a response.
Note that if you receive a success from ->can_read, but when you do attempt a sysread you receive 0 or undef, it means that the remote end disconnected or (much less likely) an error occured.use IO::Select; # Do socket creation and checking... # Now play with IO::Select so we can wait three seconds for # a result. my $selector = IO::Select->new($sock); if ($selector->can_read(3)) { # 3 second timeout. # Do reading and checking stuff... } else { # Waited three seconds and couldn't read. Bummer. }
See IO::Select for more information on using this wonderful tool.
Cheers,
Paul
P.S. In the code above you're connecting to port 80, whereas SMTP daemons like sendmail usually live on port 25. I assume this is just a typo.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: sysread()
by geektron (Curate) on Oct 09, 2001 at 10:13 UTC |