Manual Pages for UNIX Darwin command on man Net::Server::Proto
MyWebUniversity

Manual Pages for UNIX Darwin command on man Net::Server::Proto

Net::Server::Proto(3) User Contributed Perl DocumentationNet::Server::Proto(3)

NAME

Net::Server::Proto - adp0 - Net::Server Protocol compatibility layer

SYNOPSIS

# Net::Server::Proto and its accompianying modules are not

# intended to be used outside the scope of Net::Server.

# 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;

my $sock = Net::Server::Proto->object(

$defaulthost, # host to use if none found in port

$port, # port to connect to

$defaultproto, # proto to use if none found in port

$serverobj, # Net::Server object

);

### Net::Server::Proto will attempt to interface with

### sub modules named simillar to Net::Server::Proto::TCP

### Individual sub modules will be loaded by

### Net::Server::Proto as they are needed.

use Net::Server::Proto::TCP; # can be TCP/UDP/UNIX/etc

### Return an object which is a sub class of IO::Socket

### 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->object(

$defaulthost, # host to use if none found in port

$port, # port to connect to

$serverobj, # Net::Server object

);

### Log that a connection is about to occur.

### Use the facilities of the passed Net::Server object.

$sock->logconnect( $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->hupstring();

### Return the proto that is being used by this module.

my $proto = $sock->NSproto();

DESCRIPTION

Net::Server::Proto is an intermediate module which returns IO::Socket

style objects blessed into its own set of classes (ie

Net::Server::Proto::TCP, Net::Server::Proto::UNIX).

Only three or four protocols come bundled with Net::Server. TCP, UDP, UNIX, and eventually SSL. TCP is an implementation of SOCKSTREAM across an INET socket. UDP is an implementation of SOCKDGRAM across an INET socket. UNIX uses a unix style socket file and lets the user choose between SOCKSTREAM and SOCKDGRAM (the default is SOCKSTREAM). SSL is actually just a layer on top of TCP. The protocol that is passed to Net::Server can be the name of another module which contains the protocol bindings. If a protocol of MyServer::MyTCP was passed, the socket would be blessed into that

class. If Net::Server::Proto::TCP was passed, it would get that class.

If a bareword, such as tcp, udp, unix or ssl, is passed, the word is

uppercased, and post pended to "Net::Server::Proto::" (ie tcp =

Net::Server::Proto::TCP).

MMEETTHHOODDSS

Protocol names used by the Net::Server::Proto should be sub classes of

IO::Socket. These classes should also contain, as a minimum, the following methods: object Return an object which is a sub class of IO::Socket At this point the object is not connected. The method can gather any other information that it needs from the server object. Arguments are defaulthost, port, and a Net::Server style server object. logconnect Log that a connection is about to occur. Use the facilities of the passed Net::Server 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 super class. reconnect Allow for rebinding to an already open fileno. Typically will just do an fdopen using the IO::Socket super class. hupstring 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. NSproto Net::Server 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 logconnect, but simply shows a listing of which properties were found. Can be used at any time. PPOORRTT The port is the most important argument passed to the sub module

classes and to Net::Server::Proto itself. For tcp, udp, and ssl style

ports, the form is generally host:port/protocol, host|port|protocol, host/port, or port. For unix the form is generally socketfile|type|unix or socketfile.

You can see what Net::Server::Proto parsed out by looking at the logs

to see what logconnect said. You could also include a postbindhook similar to the following to debug what happened: sub postbindhook {

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";

$defhost = "defaultdomain.com";

$defproto = "tcp";

$obj = Net::Server::Proto->object($defhost,$port,$defproto);

# ref = Net::Server::Proto::TCP

# NShost = defaultdomain.com

# NSport = 20203

# NSproto = TCP

# example 2 ###################################

$port = "someother.com:20203";

$defhost = "defaultdomain.com";

$defproto = "tcp";

$obj = Net::Server::Proto->object($defhost,$port,$defproto);

# ref = Net::Server::Proto::TCP

# NShost = someother.com

# NSport = 20203

# NSproto = TCP

# example 3 ###################################

$port = "someother.com:20203/udp";

$defhost = "defaultdomain.com";

$defproto = "tcp";

$obj = Net::Server::Proto->object($defhost,$port,$defproto);

# ref = Net::Server::Proto::UDP

# NShost = someother.com

# NSport = 20203

# NSproto = UDP

# example 4 ###################################

$port = "someother.com:20203/Net::Server::Proto::UDP";

$defhost = "defaultdomain.com";

$defproto = "TCP";

$obj = Net::Server::Proto->object($defhost,$port,$defproto);

# ref = Net::Server::Proto::UDP

# NShost = someother.com

# NSport = 20203

# NSproto = UDP

# example 5 ###################################

$port = "someother.com:20203/MyObject::TCP";

$defhost = "defaultdomain.com";

$defproto = "tcp";

$obj = Net::Server::Proto->object($defhost,$port,$defproto);

# ref = MyObject::TCP

# NShost = someother.com

# NSport = 20203

# NSproto = TCP (depends on MyObject::TCP module)

# example 6 ###################################

$port = "/tmp/mysock.file|unix";

$defhost = "defaultdomain.com";

$defproto = "tcp";

$obj = Net::Server::Proto->object($defhost,$port,$defproto);

# ref = Net::Server::Proto::UNIX

# NShost = undef

# NSport = undef

# NSunixpath = /tmp/mysock.file

# NSunixtype = SOCKSTREAM

# NSproto = UNIX

# example 7 ###################################

$port = "/tmp/mysock.file|".SOCKDGRAM."|unix";

$defhost = "";

$defproto = "tcp";

$obj = Net::Server::Proto->object($defhost,$port,$defproto);

# ref = Net::Server::Proto::UNIX

# NShost = undef

# NSport = undef

# NSunixpath = /tmp/mysock.file

# NSunixtype = SOCKDGRAM

# NSproto = UNIX

# example 8 ###################################

$port = "/tmp/mysock.file|".SOCKDGRAM."|unix";

$defhost = "";

$defproto = "UNIX";

$obj = Net::Server::Proto->object($defhost,$port,$defproto);

# ref = Net::Server::Proto::UNIX

# NShost = undef

# NSport = undef

# NSunixpath = /tmp/mysock.file

# NSunixtype = SOCKDGRAM

# NSproto = UNIX

LLIICCEENNCCEE Distributed under the same terms as Net::Server

perl v5.8.8 2001-08-15 Net::Server::Proto(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™