GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Test::UNIXSock(3) User Contributed Perl Documentation Test::UNIXSock(3)

Test::UNIXSock - testing UNIX domain socket program

    use Test::UNIXSock;

    my $server = Test::UNIXSock->new(
        code => sub {
            my $path = shift;
            ...
        },
    );
    my $client = MyClient->new( sock => $server->path );
    undef $server; # kill child process on DESTROY

Using memcached:

    use Test::UNIXSock;

    my $memcached = Test::UNIXSock->new(
        code => sub {
            my $path = shift;

            exec $bin, '-s' => $path;
            die "cannot execute $bin: $!";
        },
    );
    my $memd = Cache::Memcached->new({servers => [$memcached->path]});
    ...

And functional interface is available:

    use Test::UNIXSock;
    test_unix_sock(
        client => sub {
            my ($path, $server_pid) = @_;
            # send request to the server
        },
        server => sub {
            my $path = shift;
            # run server
        },
    );

Test::UNIXSock is a test utility to test UNIX domain socket server programs.

This is based on Test::TCP.

test_unixsock
Functional interface.

    test_unixsock(
        client => sub {
            my $path = shift;
            # send request to the server
        },
        server => sub {
            my $path = shift;
            # run server
        },
        # optional
        path => "/tmp/mytest.sock", # if not specified, create a sock in tmpdir
        max_wait => 3, # seconds
    );
    
wait_unix_sock
    wait_unix_sock({ path => $path });
    

Waits for a particular path is available for connect.

my $server = Test::UNIXSock->new(%args);
Create new instance of Test::UNIXSock.

Arguments are following:

$args{auto_start}: Boolean
Call "$server->start()" after create instance.

Default: true

$args{code}: CodeRef
The callback function. Argument for callback function is: "$code->($pid)".

This parameter is required.

$args{max_wait} : Number
Will wait for at most $max_wait seconds before checking port.

See also Net::EmptyPort.

Default: 10

$server->start()
Start the server process. Normally, you don't need to call this method.
$server->stop()
Stop the server process.
my $pid = $server->pid();
Get the pid of child process.
my $port = $server->port();
Get the port number of child process.

See also Test::TCP FAQ section.

Fujiwara Shunichiro <fujiwara.shunichiro@gmail.com>

Test::TCP

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

This module is based on Test::TCP. copyright (c) 2013 by Tokuhiro Matsuno <tokuhirom@gmail.com>.

2019-04-27 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.