Name
Test::SPVM::Sys::Socket::Server - Servers for tests for SPVM::Sys::Socket
Description
Test::SPVM::Sys::Socket::Server class has methods to start servers for tests for SPVM::Sys::Socket.
Usage
Fields
socket_domain
my $socket_domain = $self->socket_domain;
A socket domain.
socket_type
my $socket_type = $self->socket_type;
A socket type.
socket_protocol
my $socket_protocol = $self->socket_protocol;
A socket protocol.
io_socket
my $io_socket = $self->io_socket;
An IO::Socket object.
listen_backlog
my $listen_backlog = $self->listen_backlog;
The length of listen backlog.
host
my $host = $self->host;
A host name for intenet domain sockets.
port
my $port = $self->port;
A port number for intenet domain sockets.
path
my $path = $self->path;
A path for UNIX domain sockets.
loop_cb
my $loop_cb = $self->loop_cb;
An anon subroutine for server main loop.
server_options
my $server_options = $self->server_options;
Server options. This should be an hash reference.
Class Methods
new
my $server_manager = Test::SPVM::Sys::Socket::Server->new(%options);
Creates a new Test::SPVM::Sys::Socket::Server object and returns it.
Options:
socket_domain
Sets "socket_domain" field to this value.
socket_type
my $socket_type = $self->socket_type;
Sets "socket_type" field to this value.
socket_protocol
my $socket_protocol = $self->socket_protocol;
Sets "socket_protocol" field to this value.
listen_backlog
my $listen_backlog = $self->listen_backlog;
Sets "listen_backlog" field to this value.
host
my $host = $self->host;
Sets "host" field to this value.
port
my $port = $self->port;
Sets "port" field to this value.
path
my $path = $self->path;
Sets "path" field to this value.
loop_cb
my $loop_cb = $self->loop_cb;
Sets "loop_cb" field to this value.
server_options
my $server_options = $self->server_options;
Sets "server_options" field to this value. This value must be a hash reference if specified.
If this option is not defined, the field is set to an emtpy hash reference.
new_echo_server_ipv4_tcp
my $server_manager = Test::SPVM::Sys::Socket::Server->new_echo_server_ipv4_tcp(%options);
Creates a new a new Test::SPVM::Sys::Socket::Server object that has the features for an IPv4-TCP echo server and returns it.
An IO::Socket::IP object is created and "io_socket" field is set to an IO::Socket::IP object.
A client can signal to the echo server that it is done writing with SHUT_WR
.
use Sys::Socket;
use Sys::Socket::Constant as SOCKET;
Sys::Socket->shutdown($socket, SOCKET->SHUT_WR);
The options %options are the same as ones of "new" method.
Instance Methods
start
$server_manager->start;
Starts the server.
This method call a subroutine stored in "loop_cb" field given the Test::SPVM::Sys::Socket::Server object at 1th argument.