|
NAMEMojo::IOLoop::Server - Non-blocking TCP and UNIX domain socket serverSYNOPSISuse Mojo::IOLoop::Server; # Create listen socket my $server = Mojo::IOLoop::Server->new; $server->on(accept => sub ($server, $handle) {...}); $server->listen(port => 3000); # Start and stop accepting connections $server->start; $server->stop; # Start reactor if necessary $server->reactor->start unless $server->reactor->is_running; DESCRIPTIONMojo::IOLoop::Server accepts TCP/IP and UNIX domain socket connections for Mojo::IOLoop.EVENTSMojo::IOLoop::Server inherits all events from Mojo::EventEmitter and can emit the following new ones.accept$server->on(accept => sub ($server, $handle) {...}); Emitted for each accepted connection. ATTRIBUTESMojo::IOLoop::Server implements the following attributes.reactormy $reactor = $server->reactor; $server = $server->reactor(Mojo::Reactor::Poll->new); Low-level event reactor, defaults to the "reactor" attribute value of the global Mojo::IOLoop singleton. Note that this attribute is weakened. METHODSMojo::IOLoop::Server inherits all methods from Mojo::EventEmitter and implements the following new ones.generate_portmy $port = Mojo::IOLoop::Server->generate_port; Find a free TCP port, primarily used for tests. handlemy $handle = $server->handle; Get handle for server, usually an IO::Socket::IP object. is_acceptingmy $bool = $server->is_accepting; Check if connections are currently being accepted. listen$server->listen(port => 3000); $server->listen({port => 3000}); Create a new listen socket. Note that TLS support depends on IO::Socket::SSL (2.009+). These options are currently available:
portmy $port = $server->port; Get port this server is listening on. start$server->start; Start or resume accepting connections. stop$server->stop; Stop accepting connections. SEE ALSOMojolicious, Mojolicious::Guides, <https://mojolicious.org>.
Visit the GSP FreeBSD Man Page Interface. |