Net::Server::Coro(3) A co-operative multithreaded server using Coro

SYNOPSIS


use Coro;
use base qw/Net::Server::Coro/;
__PACKAGE__->new->run;
sub process_request {
...
cede;
...
}

DESCRIPTION

Net::Server::Coro implements multithreaded server for the Net::Server architecture, using Coro and Coro::Socket to make all reads and writes non-blocking. Additionally, it supports non-blocking SSL negotiation.

METHODS

Most methods are inherited from Net::Server --- see it for further usage details.

new

Create new Net::Server::Coro object. It accepts these parameters (in addition to Net::Server parameters):
server_cert
Path to the SSL certificate that the server should use. This can be either relative or absolute path. Defaults to certs/server-cert.pem
server_key
Path to the SSL certificate key that the server should use. This can be either relative or absolute path. Defaults to certs/server-key.pem

proto_object HOST, PORT, PROTO

Wraps socket creation, turning all socket types into Net::Server::Proto::Coro objects.

loop

The main loop uses starts a number of Coro coroutines:
  • One for each listening socket.
  • One for each active connection. Since these may respawn on a firlay frequent basis, ``async_pool'' in Coro is used to maintain a pool of coroutines.
  • An AnyEvent infinite wait, which equates to the ``run the event loop.''

server_cert [PATH]

Gets or sets the path of the SSL certificate used by the server.

server_key [PATH]

Gets or sets the path of the SSL key file used by the server.

DEPENDENCIES

Coro, AnyEvent, Net::Server

BUGS AND LIMITATIONS

The client filehandle, socket, and peer information all use Coro::Specific in order to constrain their information to their coroutine. Attempting to access them from a different coroutine will yield possibly unexpected results.

Generally, all those of Coro. Please report any bugs or feature requests specific to Net::Server::Coro to "[email protected]", or through the web interface at <http://rt.cpan.org>.

AUTHORS

Alex Vandiver "<[email protected]>"; code originally from Audrey Tang "<[email protected]>"

COPYRIGHT

Copyright 2006 by Audrey Tang <[email protected]>

Copyright 2007-2008 by Best Practical Solutions

This software is released under the MIT license cited below.

The MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ``Software''), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.