The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

LWP::Conn::_Connect - event driven connection establishment

SYNOPSIS

  require LWP::Conn::_Connect;
  $conn = LWP::Conn::_Connect->new($host, $port, $timeout, $class, $opaque);

DESCRIPTION

The LWP::Conn::_Connect class encapsulate event driven Internet socket connection establishment. The constructor is called with a hostname and a port to connect to, and will return an object derived from IO::Socket::INET if connection establishment has been performed or is in progress. If the connection attempt fails right away then undef is returned and $! will be the errno that connect(2) set.

When the outcome of the connection attempt has been determined, then the LWP::Conn::_Connect object will be re-blessed into the given $class and one of the following methods will be called on it:

$conn->connected($opaque)

Successful connection establishment. The $conn is now connected. This call can even by made before the LWP::Conn::_Connect constructor returns. The $opaque value passed to the LWP::Conn::_Connect constructor is passed as argument.

$conn->connect_failed($errmsg, $opaque)

All addresses has been tried and all of them failed. The error from the last connection attempt is passed as the first argument. The $opaque value passed to the LWP::Conn::_Connect constructor is passed as the second.

The $timeout value says how many seconds to allow for each connection attempt. A value of 0 indicate no timeout. The $host argument can be a single scalar or an array of scalar host names. The $port argument must be numeric.

BUGS

The gethostbyname(3) call used in the constructor is blocking.

COPYRIGHT

Copyright 1998, Gisle Aas

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.