This module was written to imitate the IO::Socket::INET API, and derive from it. Since IO::Socket::INET
does not support IPv6, this module does neither.
Therefore it is not recommended to use Coro::Socket in new code. Instead, use AnyEvent::Socket and
Coro::Handle, e.g.:
use Coro;
use Coro::Handle;
use AnyEvent::Socket;
# use tcp_connect from AnyEvent::Socket
# and call Coro::Handle::unblock on it.
tcp_connect "www.google.com", 80, Coro::rouse_cb;
my $fh = unblock +(Coro::rouse_wait)[0];
# now we have a perfectly thread-safe socket handle in $fh
print $fh "GET / HTTP/1.0\015\012\015\012";
local $/;
print <$fh>;
Using "AnyEvent::Socket::tcp_connect" gives you transparent IPv6, multi-homing, SRV-record etc. support.
For listening sockets, use "AnyEvent::Socket::tcp_server".
$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", "SO_RCVBUF", "SO_SNDBUF".
$fh = new Coro::Socket PeerHost => "localhost", PeerPort => 'finger';