Name
Test::SPVM::Sys::Socket::ServerManager::UNIX - Server Manager for tests for UNIX Domain Sockets
Description
Test::SPVM::Sys::Socket::ServerManager::UNIX class is a server manager for tests for UNIX domain sockets.
Usage
use Test::SPVM::Sys::Socket::ServerManager::UNIX;
my $server_manager = Test::SPVM::Sys::Socket::ServerManager::UNIX->new(
code => sub {
my ($server_manager) = @_;
my $path = $server_manager->path;
my $server = Test::SPVM::Sys::Socket::Server->new_echo_server_unix_tcp(path => $path);
$server->start;
},
);
Details
This class is originally a Test::UNIXSock porting for tests for SPVM::Sys::Socket.
Super Class
Test::SPVM::Sys::Socket::ServerManager
Fields
path
my $path = $self->path;
The path to which the server binds.
tmpdir
A temporary directory used by "path".
Class Methods
new
my $server = Test::SPVM::Sys::Socket::ServerManager::UNIX->new(%options);
Calls new method in its super class and returns its return value.
Options:
The following options are available adding the options of new method in its super class.
path
Sets "path" field to this value.
Instance Methods
init_fields
$server->init_fields(%options);
Calls init_fields method in its super class and sets fields of this calss.
"path" field is set to the value of path
option.
If path
option is not defind, tmpdir field is set to a temporary directory and "path" is set to an available path.
This method is a protected method, so it should only be called in this class and its child classes.
start
$server->start($code);
Starts a server process given an anon subroutine $code.
This method calls fork function and starts the server specified by $code in the child process.
The Test::SPVM::Sys::Socket::ServerManager::UNIX object is passed to the 1th argument of $code.
$server->start(sub {
my ($server_manager) = @_;
my $path = $server_manager->path;
});
The parent process waits until the server starts.