# Net::Server::Proto - Net::Server Protocol compatibility layer - perldoc - [phpMan]

## NAME
    [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown) - [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown) Protocol compatibility layer

## SYNOPSIS
        NOTE: beginning in [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown) 2.005, the default value for
              ipv is IPv* meaning that if no host is passed, or
              a hostname is past, all available socket types will be
              bound.  You can force IPv4 only by adding an ipv => 4
              configuration in any of the half dozen ways we let you
              specify it.

        NOTE: For IPv6 [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown) will first try and use the module
              listed in server config ipv6_package, then
              $[Net::Server::ipv6_package](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3Aipv6package/markdown), then [IO::Socket::IP](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3AIP/markdown), then
              [IO::Socket::INET6](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3AINET6/markdown) (which is deprecated).

        # [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown) and its accompanying modules are not
        # intended to be used outside the scope of [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown).

        # That being said, here is how you use them.  This is
        # only intended for anybody wishing to extend the
        # protocols to include some other set (ie maybe a
        # database connection protocol)

        use [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown);

        my @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info(
            $port,            # port to connect to
            $default_host,    # host to use if none found in port
            $default_proto,   # proto to use if none found in port
            $default_ipv,     # default of IPv6 or IPv4 if none found in port
            $server_obj,      # [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown) object
        );

        my @raw_info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->get_addr_info($host, $port, $proto);
        # returns arrayref of resolved ips, ports, and ipv values

        my $sock = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->object({
            port  => $port,
            host  => $host,
            proto => $proto,
            ipv   => $ipv, # * (IPv*) if false (default false)
        }, $server);

        # [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown) will attempt to interface with
        # sub modules named similar to [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)
        # Individual sub modules will be loaded by
        # [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown) as they are needed.

        use [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown); # or UDP or UNIX etc

        # Return an object which is a sub class of [IO::Socket](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket/markdown)
        # At this point the object is not connected.
        # The method can gather any other information that it
        # needs from the server object.
        my $sock = [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)->object({
            port  => $port,
            host  => $host,
            proto => $proto,
            ipv   => 6, # IPv6 - default is * - can also be '4'
        }, $server);


        # Log that a connection is about to occur.
        # Use the facilities of the passed [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown) object.
        $sock->log_connect( $server );

        # Actually bind to port or socket file.  This
        # is typically done by calling the configure method.
        $sock->connect();

        # Allow for rebinding to an already open fileno.
        # Typically will just do an fdopen.
        $sock->reconnect();

        ### Return a unique identifying string for this sock that
        # can be used when reconnecting.
        my $str = $sock->hup_string();

        # Return the proto that is being used by this module.
        my $proto = $sock->NS_proto();

## DESCRIPTION
    [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown) is an intermediate module which returns [IO::Socket](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket/markdown) style objects blessed into
    its own set of classes (ie [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown), [Net::Server::Proto::UNIX](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3AUNIX/markdown)).

    Only three or four protocols come bundled with [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown). TCP, UDP, UNIX, UNIXDGRAM, and
    SSLEAY. TCP is an implementation of SOCK_STREAM across an INET socket. UDP is an implementation
    of SOCK_DGRAM across an INET socket. UNIX uses a unix style socket file with the SOCK_STREAM
    protocol. UNIXGRAM uses a unix style socket file with the SOCK_DGRAM protocol. SSLEAY is
    actually just a layer on top of TCP but uses [Net::SSLeay](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3ASSLeay/markdown) to read and write from the stream.

    The protocol that is passed to [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown) can be the name of another module which contains the
    protocol bindings. If a protocol of [MyServer::MyTCP](https://www.chedong.com/phpMan.php/perldoc/MyServer%3A%3AMyTCP/markdown) was passed, the socket would be blessed into
    that class. If [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown) was passed, it would get that class. If a bareword, such
    as tcp, udp, unix, unixdgram or ssleay, is passed, the word is uppercased, and post pended to
    "[Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)::" (ie tcp = [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)).

## METHODS
    Protocol names used by the [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown) should be sub classes of [IO::Socket](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket/markdown). These classes
    should also contain, as a minimum, the following methods should be provided:

    object
        Return an object which is a sub class of [IO::Socket](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket/markdown) At this point the object is not
        connected. The method can gather any other information that it needs from the server object.
        Arguments are default_host, port, and a [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown) style server object.

    log_connect
        Log that a connection is about to occur. Use the facilities of the passed [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown)
        object. This should be an informative string explaining which properties are being used.

    connect
        Actually bind to port or socket file. This is typically done internally by calling the
        configure method of the [IO::Socket](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket/markdown) super class.

    reconnect
        Allow for rebinding to an already open fileno. Typically will just do an fdopen using the
        [IO::Socket](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket/markdown) super class.

    hup_string
        Return a unique identifying string for this sock that can be used when reconnecting. This is
        done to allow information including the file descriptor of the open sockets to be passed via
        %ENV during an exec. This string should always be the same based upon the configuration
        parameters.

    NS_port
        [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown) protocol. Return the port that is being used by this module. If the underlying
        type is UNIX then port will actually be the path to the unix socket file.

    NS_host
        [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown) protocol. Return the protocol that is being used by this module. This does not
        have to be a registered or known protocol.

    NS_proto
        [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown) protocol. Return the protocol that is being used by this module. This does not
        have to be a registered or known protocol.

    show
        Similar to log_connect, but simply shows a listing of which properties were found. Can be
        used at any time.

## HOST
    The hostname may be either blank, '*', be an IPv4 address, an IPv6 address, a bare hostname, or
    a hostname with IPv* specifications.

        host => "127.0.0.1",  # an IPv4 address

        host => "::1",        # an IPv6 address

        host => 'localhost',  # addresses returned by localhost (default IPv* - IPv4 and/or IPv6)

        host => 'localhost/IPv*',  # same

        ipv  => '*',
        host => 'localhost',  # same

        ipv  => 6,
        host => 'localhost',  # addresses returned by localhost (IPv6)

        ipv  => 'IPv4 IPv6',
        host => 'localhost',  # addresses returned by localhost (requires IPv6 and IPv4)


        host => '*',          # any local interfaces (default IPv*)

        ipv  => '*',
        host => '*',          # any local interfaces (any IPv6 or IPv4)

        host => '*/IPv*',     # same

## IPV
    In addition to being able to specify IPV as a separate parameter, ipv may also be passed as a
    part of the host, as part of the port, as part of the protocol or may be specified via
    $ENV{'IPV'}. The order of precedence is as follows:

         1) Explicit IPv4 or IPv6 address - wins
         2) ipv specified in port
         3) ipv specified in host
         4) ipv specified in proto
         5) ipv specified in default settings
         6) ipv specified in $ENV{'IPV'}
         7) default to IPv*

## PORT
    The port is the most important argument passed to the sub module classes and to
    [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown) itself. For tcp, udp, and ssleay style ports, the form is generally
    host:port/protocol, [host]:port/protocol, host|port|protocol, host/port, or port. If *host* is a
    numerical IPv6 address it should be enclosed in square brackets to avoid ambiguity in parsing a
    port number, e.g.: "[::1]:80". Separating with spaces, commas, or pipes is also allowed, e.g.
    "::1, 80". For unix sockets the form is generally socket_file|unix or socket_file.

    To help overcome parsing ambiguity, it is also possible to pass port as a hashref (or as an
    array of hashrefs) of information such as:

        port => {
            host  => "localhost",
            ipv   => 6, # could also pass IPv6 (* is default)
            port  => 20203,
            proto => 'tcp',
        }

    If a hashref does not include host, ipv, or proto - it will use the default value supplied by
    the general configuration.

    A socket protocol family PF_INET or PF_INET6 is derived from a specified address family of the
    binding address. A PF_INET socket can only accept IPv4 connections. A PF_INET6 socket accepts
    IPv6 connections, but may also accept IPv4 connections, depending on OS and its settings. For
    example, on FreeBSD systems setting a sysctl net.inet6.ip6.v6only to 0 will allow IPv4
    connections to a PF_INET6 socket. By default on linux, binding to host [::] will accept IPv4 or
    IPv6 connections.

    The [Net::Server::Proto::object](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3Aobject/markdown) method returns a list of objects corresponding to created
    sockets. For Unix and INET sockets the list typically contains just one element, but may return
    multiple objects when multiple protocol families are allowed or when a host name resolves to
    multiple local binding addresses. This is particularly true when an ipv value of '*' is passed
    in allowing hostname resolution.

    You can see what [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown) parsed out by looking at the logs to see what log_connect
    said. You could also include a post_bind_hook similar to the following to debug what happened:

        sub post_bind_hook {
            my $self = shift;
            foreach my $sock ( @{ $self->{server}->{sock} } ){
                $self->log(2,$sock->show);
            }
        }

    Rather than try to explain further, please look at the following examples:

        # example 1 #----------------------------------

        $port      = "20203";
        $def_host  = "default-domain.com";
        $def_proto = undef;
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = {
        #     host  => 'default-domain.com',
        #     port  => 20203,
        #     proto => 'tcp', # will use [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)
        #     ipv   => *, # IPv*
        # };

        # example 2 #----------------------------------

        $port      = "someother.com:20203";
        $def_host  = "default-domain.com";
        $def_proto = "tcp";
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = {
        #     host  => 'someother.com',
        #     port  => 20203,
        #     proto => 'tcp', # will use [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)
        #     ipv   => *,
        # };

        # example 3 #----------------------------------

        $port      = "someother.com:20203/udp";
        $def_host  = "default-domain.com";
        $def_proto = "tcp";
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = {
        #     host  => 'someother.com',
        #     port  => 20203,
        #     proto => 'udp', # will use [Net::Server::Proto::UDP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3AUDP/markdown)
        #     ipv   => *,
        # };

        # example 4 #----------------------------------

        $port      = "someother.com:20203/[Net::Server::Proto::UDP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3AUDP/markdown)";
        $def_host  = "default-domain.com";
        $def_proto = "TCP";
        $def_ipv   = 4;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = {
        #     host  => 'someother.com',
        #     port  => 20203,
        #     proto => '[Net::Server::Proto::UDP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3AUDP/markdown)',
        #     ipv   => 4,
        # };

        # example 5 #----------------------------------

        $port      = "someother.com:20203/[MyObject::TCP](https://www.chedong.com/phpMan.php/perldoc/MyObject%3A%3ATCP/markdown)";
        $def_host  = "default-domain.com";
        $def_proto = "tcp";
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto);
        # @info = {
        #     host  => 'someother.com',
        #     port  => 20203,
        #     proto => '[MyObject::TCP](https://www.chedong.com/phpMan.php/perldoc/MyObject%3A%3ATCP/markdown)',
        # };

        # example 6 #----------------------------------

        $port      = "/tmp/mysock.file|unix";
        $def_host  = "default-domain.com";
        $def_proto = "tcp";
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = {
        #     host  => '*', # irrelevant for UNIX socket
        #     port  => '/tmp/mysock.file', # not really a port
        #     proto => 'unix', # will use [Net::Server::Proto::UNIX](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3AUNIX/markdown)
        #     ipv   => '*', # irrelevant for UNIX socket
        # };

        # example 7 #----------------------------------

        $port      = "/tmp/mysock.file|unixdgram";
        $def_host  = "default-domain.com";
        $def_proto = "tcp";
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = {
        #     host  => '*', # irrelevant for UNIX socket
        #     port  => '/tmp/mysock.file', # not really a port
        #     proto => 'unixdgram', # will use [Net::Server::Proto::UNIXDGRAM](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3AUNIXDGRAM/markdown)
        #     ipv   => '*', # irrelevant for UNIX socket
        # };

        # example 8 #----------------------------------

        $port      = "/tmp/mysock.file|SOCK_STREAM|unix"; # legacy
        $def_host  = "";
        $def_proto = "tcp";
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = {
        #     host  => '*', # irrelevant for UNIX socket
        #     port  => '/tmp/mysock.file', # not really a port
        #     proto => 'unix', # will use [Net::Server::Proto::UNIX](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3AUNIX/markdown)
        #     unix_type => 'SOCK_STREAM',
        #     ipv   => '*', # irrelevant for UNIX socket
        # };

        # example 9 #----------------------------------

        $port      = "/tmp/mysock.file|SOCK_DGRAM|unix"; # legacy
        $def_host  = "";
        $def_proto = "tcp";
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = {
        #     host  => '*', # irrelevant for UNIX socket
        #     port  => '/tmp/mysock.file', # not really a port
        #     proto => 'unix', # will use [Net::Server::Proto::UNIXDGRAM](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3AUNIXDGRAM/markdown)
        #     unix_type => 'SOCK_DGRAM',
        #     ipv   => '*', # irrelevant for UNIX socket
        # };

        # example 10 #----------------------------------

        $port = "someother.com:20203/ssleay";
        $def_host  = "default-domain.com";
        $def_proto = "tcp";
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = {
        #     host  => 'someother.com',
        #     port  => 20203,
        #     proto => 'ssleay', # will use [Net::Server::Proto::SSLEAY](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ASSLEAY/markdown)
        #     ipv   => *,
        # };

        # example 11 #----------------------------------

        $port = "[::1]:20203 ipv6 tcp";
        $def_host  = "default-domain.com";
        $def_proto = "tcp";
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = {
        #     host  => '::1',
        #     port  => 20203,
        #     proto => 'tcp', # will use [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)
        #     ipv   => 6,
        # };

        # example 12 #----------------------------------

        $port = "[::1]:20203 tcp";
        $def_host  = "default-domain.com/IPv6";
        $def_proto = "tcp";
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = {
        #     host  => '::1',
        #     port  => 20203,
        #     proto => 'tcp', # will use [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)
        #     ipv   => 6,
        # };

        # example 13 #----------------------------------

        $port = "[someother.com]:20203 ipv6 ipv4 tcp";
        $def_host  = "default-domain.com";
        $def_proto = "tcp";
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = ({
        #     host  => 'someother.com',
        #     port  => 20203,
        #     proto => 'tcp', # will use [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)
        #     ipv   => 4,
        # }, {
        #     host  => 'someother.com',
        #     port  => 20203,
        #     proto => 'tcp', # will use [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)
        #     ipv   => 6,
        # });

        # example 14 #----------------------------------

        # depending upon your configuration
        $port = "localhost:20203";
        $def_host  = "default-domain.com";
        $def_proto = "tcp";
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = ({
        #     host  => '127.0.0.1',
        #     port  => 20203,
        #     proto => 'tcp', # will use [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)
        #     ipv   => 4, # IPv4
        # }, {
        #     host  => '::1',
        #     port  => 20203,
        #     proto => 'tcp', # will use [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)
        #     ipv   => 6, # IPv6
        # });

        # example 15 #----------------------------------

        # depending upon your configuration
        $port = "localhost:20203";
        $def_host  = "default-domain.com IPv*";
        $def_proto = "tcp";
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = ({
        #     host  => '127.0.0.1',
        #     port  => 20203,
        #     proto => 'tcp', # will use [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)
        #     ipv   => 4, # IPv4
        # }, {
        #     host  => '::1',
        #     port  => 20203,
        #     proto => 'tcp', # will use [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)
        #     ipv   => 6, # IPv6
        # });

        # example 16 #----------------------------------

        # depending upon your configuration
        $ENV{'IPV'} = '4';
        $port = "localhost:20203";
        $def_host  = "default-domain.com";
        $def_proto = "tcp";
        $def_ipv   = undef;
        @info = [Net::Server::Proto](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto/markdown)->parse_info($port,$def_host,$def_proto,$def_ipv);
        # @info = ({
        #     host  => '127.0.0.1',
        #     port  => 20203,
        #     proto => 'tcp', # will use [Net::Server::Proto::TCP](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3AProto%3A%3ATCP/markdown)
        #     ipv   => 4, # IPv4
        # });

## LICENCE
    Distributed under the same terms as [Net::Server](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer/markdown)

