.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.37 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' .\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Net::Server::Proto 3" .TH Net::Server::Proto 3 "2007-02-02" "perl v5.8.8" "User Contributed Perl Documentation" .SH "NAME" .Vb 1 \& Net::Server::Proto - Net::Server Protocol compatibility layer .Ve .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& # Net::Server::Proto and its accompianying modules are not \& # intended to be used outside the scope of Net::Server. .Ve .PP .Vb 4 \& # 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) .Ve .PP .Vb 1 \& use Net::Server::Proto; .Ve .PP .Vb 6 \& my $sock = Net::Server::Proto->object( \& $default_host, # host to use if none found in port \& $port, # port to connect to \& $default_proto, # proto to use if none found in port \& $server_obj, # Net::Server object \& ); .Ve .PP .Vb 4 \& ### 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. .Ve .PP .Vb 1 \& use Net::Server::Proto::TCP; # can be TCP/UDP/UNIX/etc .Ve .PP .Vb 9 \& ### 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( \& $default_host, # host to use if none found in port \& $port, # port to connect to \& $server_obj, # Net::Server object \& ); .Ve .PP .Vb 3 \& ### Log that a connection is about to occur. \& ### Use the facilities of the passed Net::Server object. \& $sock->log_connect( $server ); .Ve .PP .Vb 3 \& ### Actually bind to port or socket file. This \& ### is typically done by calling the configure method. \& $sock->connect(); .Ve .PP .Vb 3 \& ### Allow for rebinding to an already open fileno. \& ### Typically will just do an fdopen. \& $sock->reconnect(); .Ve .PP .Vb 3 \& ### Return a unique identifying string for this sock that \& ### can be used when reconnecting. \& my $str = $sock->hup_string(); .Ve .PP .Vb 2 \& ### Return the proto that is being used by this module. \& my $proto = $sock->NS_proto(); .Ve .SH "DESCRIPTION" .IX Header "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). .PP Only three or four protocols come bundled with Net::Server. \&\s-1TCP\s0, \s-1UDP\s0, \s-1UNIX\s0, and eventually \s-1SSL\s0. \s-1TCP\s0 is an implementation of \s-1SOCK_STREAM\s0 across an \s-1INET\s0 socket. \s-1UDP\s0 is an implementation of \s-1SOCK_DGRAM\s0 across an \s-1INET\s0 socket. \s-1UNIX\s0 uses a unix style socket file and lets the user choose between \s-1SOCK_STREAM\s0 and \&\s-1SOCK_DGRAM\s0 (the default is \s-1SOCK_STREAM\s0). \s-1SSL\s0 is actually just a layer on top of \s-1TCP\s0. .PP 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 \*(L"Net::Server::Proto::\*(R" (ie tcp = Net::Server::Proto::TCP). .SH "METHODS" .IX Header "METHODS" 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: .IP "object" 4 .IX Item "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 default_host, port, and a Net::Server style server object. .IP "log_connect" 4 .IX Item "log_connect" 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. .IP "connect" 4 .IX Item "connect" Actually bind to port or socket file. This is typically done internally by calling the configure method of the IO::Socket super class. .IP "reconnect" 4 .IX Item "reconnect" Allow for rebinding to an already open fileno. Typically will just do an fdopen using the IO::Socket super class. .IP "hup_string" 4 .IX Item "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 \f(CW%ENV\fR during an exec. This string should always be the same based upon the configuration parameters. .IP "NS_proto" 4 .IX Item "NS_proto" Net::Server protocol. Return the protocol that is being used by this module. This does not have to be a registered or known protocol. .IP "show" 4 .IX Item "show" Similar to log_connect, but simply shows a listing of which properties were found. Can be used at any time. .SH "PORT" .IX Header "PORT" 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 socket_file|type|unix or socket_file. .PP You can see what Net::Server::Proto 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: .PP .Vb 6 \& sub post_bind_hook { \& my $self = shift; \& foreach my $sock ( @{ $self->{server}->{sock} } ){ \& $self->log(2,$sock->show); \& } \& } .Ve .PP Rather than try to explain further, please look at the following examples: .PP .Vb 1 \& # example 1 ################################### .Ve .PP .Vb 4 \& $port = "20203"; \& $def_host = "default_domain.com"; \& $def_proto = "tcp"; \& $obj = Net::Server::Proto->object($def_host,$port,$def_proto); .Ve .PP .Vb 4 \& # ref = Net::Server::Proto::TCP \& # NS_host = default_domain.com \& # NS_port = 20203 \& # NS_proto = TCP .Ve .PP .Vb 1 \& # example 2 ################################### .Ve .PP .Vb 4 \& $port = "someother.com:20203"; \& $def_host = "default_domain.com"; \& $def_proto = "tcp"; \& $obj = Net::Server::Proto->object($def_host,$port,$def_proto); .Ve .PP .Vb 4 \& # ref = Net::Server::Proto::TCP \& # NS_host = someother.com \& # NS_port = 20203 \& # NS_proto = TCP .Ve .PP .Vb 1 \& # example 3 ################################### .Ve .PP .Vb 4 \& $port = "someother.com:20203/udp"; \& $def_host = "default_domain.com"; \& $def_proto = "tcp"; \& $obj = Net::Server::Proto->object($def_host,$port,$def_proto); .Ve .PP .Vb 4 \& # ref = Net::Server::Proto::UDP \& # NS_host = someother.com \& # NS_port = 20203 \& # NS_proto = UDP .Ve .PP .Vb 1 \& # example 4 ################################### .Ve .PP .Vb 4 \& $port = "someother.com:20203/Net::Server::Proto::UDP"; \& $def_host = "default_domain.com"; \& $def_proto = "TCP"; \& $obj = Net::Server::Proto->object($def_host,$port,$def_proto); .Ve .PP .Vb 4 \& # ref = Net::Server::Proto::UDP \& # NS_host = someother.com \& # NS_port = 20203 \& # NS_proto = UDP .Ve .PP .Vb 1 \& # example 5 ################################### .Ve .PP .Vb 4 \& $port = "someother.com:20203/MyObject::TCP"; \& $def_host = "default_domain.com"; \& $def_proto = "tcp"; \& $obj = Net::Server::Proto->object($def_host,$port,$def_proto); .Ve .PP .Vb 4 \& # ref = MyObject::TCP \& # NS_host = someother.com \& # NS_port = 20203 \& # NS_proto = TCP (depends on MyObject::TCP module) .Ve .PP .Vb 1 \& # example 6 ################################### .Ve .PP .Vb 4 \& $port = "/tmp/mysock.file|unix"; \& $def_host = "default_domain.com"; \& $def_proto = "tcp"; \& $obj = Net::Server::Proto->object($def_host,$port,$def_proto); .Ve .PP .Vb 6 \& # ref = Net::Server::Proto::UNIX \& # NS_host = undef \& # NS_port = undef \& # NS_unix_path = /tmp/mysock.file \& # NS_unix_type = SOCK_STREAM \& # NS_proto = UNIX .Ve .PP .Vb 1 \& # example 7 ################################### .Ve .PP .Vb 4 \& $port = "/tmp/mysock.file|".SOCK_DGRAM."|unix"; \& $def_host = ""; \& $def_proto = "tcp"; \& $obj = Net::Server::Proto->object($def_host,$port,$def_proto); .Ve .PP .Vb 6 \& # ref = Net::Server::Proto::UNIX \& # NS_host = undef \& # NS_port = undef \& # NS_unix_path = /tmp/mysock.file \& # NS_unix_type = SOCK_DGRAM \& # NS_proto = UNIX .Ve .PP .Vb 1 \& # example 8 ################################### .Ve .PP .Vb 4 \& $port = "/tmp/mysock.file|".SOCK_DGRAM."|unix"; \& $def_host = ""; \& $def_proto = "UNIX"; \& $obj = Net::Server::Proto->object($def_host,$port,$def_proto); .Ve .PP .Vb 6 \& # ref = Net::Server::Proto::UNIX \& # NS_host = undef \& # NS_port = undef \& # NS_unix_path = /tmp/mysock.file \& # NS_unix_type = SOCK_DGRAM \& # NS_proto = UNIX .Ve .SH "LICENCE" .IX Header "LICENCE" Distributed under the same terms as Net::Server