NAME

Net::TCP::Server - TCP sockets interface module for listeners and servers

SYNOPSIS

use Socket;			# optional
use Net::Gen;		# optional
use Net::Inet;		# optional
use Net::TCP;		# optional
use Net::TCP::Server;

DESCRIPTION

The Net::TCP::Server module provides services for TCP communications over sockets. It is layered atop the Net::TCP, Net::Inet, and Net::Gen modules, which are part of the same distribution.

Public Methods

The following methods are provided by the Net::TCP::Server module itself, rather than just being inherited from Net::TCP, Net::Inet, or Net::Gen.

new

Usage:

$obj = new Net::TCP::Server;
$obj = new Net::TCP::Server $service;
$obj = new Net::TCP::Server $service, \%parameters;
$obj = new Net::TCP::Server $lcladdr, $service, \%parameters;

Returns a newly-initialised object of the given class. This is much like the regular new method of the other modules in this distribution, except that it makes it easier to specify just a service name or port number, and it automatically does a setsockopt() call to set SO_REUSEADDR to make the bind() more likely to succeed. The SO_REUSEADDR is really done in a base class, but it's enabled by defaulting the reuseaddr object parameter to 1 in this constructor.

Simple example for server setup:

    $lh = new Net::TCP::Server 7788 or die;
    while ($sh = $lh->accept) {
	defined($pid=fork) or die "fork: $!\n";
	if ($pid) {		# parent doesn't need client fh
	    $sh->stopio;
	    next;
	}
	# child doesn't need listener fh
	$lh->stopio;
	# do per-connection stuff here
	exit;
    }

Note that signal-handling for the child processes is not included in this example. A sample server will be included in the final kit which will show how to manage the subprocesses.

Protected Methods

none.

Known Socket Options

There are no socket options specific to the Net::TCP::Server module.

Known Object Parameters

There are no object parameters registered by the Net::TCP::Server module itself.

Exports

default

none

exportable

none

tags

none

AUTHOR

Spider Boardman <spider@Orb.Nashua.NH.US>