On Tue, Apr 23, 2002 at 12:55:34PM -0400, Peter Chen wrote:
> 
> Interestingly enough, open_ssl itself seems to allow non-blocking mode. 
> There is an example using select and nonblocking sockets in pages
> 279-282 of Eric Rescorla's SSL and TLS book (ISBN 0-201-61598-3).

It can take a long time to build a TCP socket and even longer to
determine the socket can't be built.  Connecting in non-blocking mode
will let other things happen while TCP works out the details.  Once
the socket is built, it can be made to block again.

> On Mon, 2002-04-22 at 21:25, Rocco Caputo wrote:
> > Perhaps PoCo::UserAgent can create the socket in blocking mode?  I'm
> > not sure what sort of effect that will have on multitasking within
> > POE.
> 
> Yeah, it seems to work better w/ SSL when I change the
> $object->nonblock(1) to nonblock(0).
> 
>   sub spawn
>   {
>       my $class = @_ ? shift : 'POE::Component::Client::UserAgent';
>       $class = ref $class || $class;
>       my $object = $class -> SUPER::new;
>       bless $object, $class;
>       $object -> nonblock (0);
> ...
> 
> The question as you pointed out is whether this will have some adverse
> effects.  For example, is it possible to block during reading and
> writing after select indicates that it's ready to be read or written? 
> If it does block, would setting timeout (to something much shorter than
> 180 seconds) for PoCoCl::UserAgent help?

I'm pretty sure it will have a problem if the socket is truly blocking
while it's being created.  The program will stall until the socket
connects or fails.

I've used POE::Wheel::SocketFactory to create plain sockets without
blocking.  Once the connection succeeds, I've made it secure by
turning blocking back on and tie()'ing a modified Net::SSLeay::Handle
class to the socket.

See <http://poe.dynodns.net/~troc/tmp/poing-ssl.perl>.  It requires
POE 0.19.

-- Rocco Caputo / [EMAIL PROTECTED] / poe.perl.org / poe.sf.net

Reply via email to