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

NAME

Coro::Socket - non-blocking socket-I/O

SYNOPSIS

 use Coro::Socket;

 # listen on an ipv4 socket
 my $socket = new Coro::Socket PeerHost => "localhost",
                               PeerPort => 'finger';

 # listen on any other type of socket
 my $socket = Coro::Socket->new_from_fh
                 (IO::Socket::UNIX->new
                     Local  => "/tmp/socket",
                     Type   => SOCK_STREAM,
                 );

DESCRIPTION

This module is an AnyEvent user, you need to make sure that you use and run a supported event loop.

This module implements socket-handles in a coroutine-compatible way, that is, other coroutines can run while reads or writes block on the handle. See Coro::Handle, especially the note about prefering method calls.

$fh = new Coro::Socket param => value, ...

Create a new non-blocking tcp handle and connect to the given host and port. The parameter names and values are mostly the same as for IO::Socket::INET (as ugly as I think they are).

The parameters officially supported currently are: ReuseAddr, LocalPort, LocalHost, PeerPort, PeerHost, Listen, Timeout.

   $fh = new Coro::Socket PeerHost => "localhost", PeerPort => 'finger';

AUTHOR

 Marc Lehmann <schmorp@schmorp.de>
 http://home.schmorp.de/