NAME

ControlFreak::Socket - Defines a (shared) socket controlled by ControlFreak

SYNOPSIS

$sock = ControlFreak::Socket->new(
    ctrl    => $ctrl,
    name    => "fcgisock",
    host    => "unix/",
    service => "/tmp/cfk-x.sock",
    options => "TBD",
);
$sock->bind;
$sock->unbind;
$sock->set_host;
$sock->set_service;
print $sock->service;

DESCRIPTION

Each socket object has a unique name inside ControlFreak controller, services interested in a socket just reference it using this name. The controller pipes the socket to children's stdin after forking, and before executing the service.

METHODS

new(%param)

Creates a socket objects. Params are:

  • ctrl

    The controller to attach the socket to. If not specified, the socket object won't be created, new() will just return undef.

  • name

    The name of the socket, MUST be unique within ctrl.

  • host

    eg. '127.0.0.0', '0.0.0.0', 'unix/', '[::1]'.

  • service

    eg. '80', '/tmp/cfk.sock'.

If a socket with that name already exists, it will return undef and log the error.

bind

Creates, binds the socket and puts it in listen mode, then returns immediately. Once bound, $socket->fh will return the filehandle.

is_bound

Returns true if the socket is bound.

unbind()

Unbind and destroys the socket.

AUTHOR

Yann Kerherve <yannk@cpan.org>