Name

Test::SPVM::Sys::Socket::ServerManager - Server Manager Base Class for Tests for Sockets.

Description

Test::SPVM::Sys::Socket::ServerManager is a base class for server managers for tests for sockets.

Usage

This class is a base class, so it should not be used directory.

See usage sections of "Well Known Child Class".

Fields

pid

my $pid = $self->pid;

The child process ID created by fork function.

my_pid

my $my_pid = $self->my_pid;

The parent process ID created by fork function.

auto_start

my $auto_start = $self->auto_start;

If this field is a true value, "new" method calls "start" method, otherwise does not call it.

max_wait

my $max_wait = $self->max_wait;

The maximum number of times to wait to check that a server has been started by a child process created by fork function..

code

my $code = $self->code;

An anon subroutine to run a server.

host

my $host = $self->host;

A host name.

Class Methods

new

my $server = Test::SPVM::Sys::Socket::ServerManager->new(%options);

Creates a new Test::SPVM::Sys::Socket::ServerManager object and returns it.

This method calls "init_fields" methods.

If "auto_start" field is a true value, this method calls "start" method.

Options:

Instance Methods

init_fields

$server->init_fields(%options);

"max_wait" field is set to the value of max_wait option.

If max_wait option is not defind, it is set to 10.

"auto_start" field is set to the value of auto_start option.

If auto_start option is not defind, it is set to 1.

"my_pid" field is set to the current process ID.

"code" field is set to the value of code option.

If code option is not defind, an exception is thrown.

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 parent process waits until the server starts.

This method is planed to be implemented in child classes.

stop

$server->stop;

Stops the server process stared by "start" method.

DESTROY

The destructor.

This method calls "stop" method.

Well Known Child Class