Coro::Socket man page on Pidora

Man page or keyword search:  
man Server   31170 pages
apropos Keyword Search (all sections)
Output format
Pidora logo
[printable version]

Socket(3)	      User Contributed Perl Documentation	     Socket(3)

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.

IPV6 WARNING
       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';

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

perl v5.14.2			  2011-11-11			     Socket(3)
[top]

List of man pages available for Pidora

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net