NAME
Net::NBsocket -- Non-Blocking Sockets
SYNOPSIS
use Net::NBsocket qw(
open_UDP
open_udpNB
open_Listen
open_listenNB
connectBlk
connect_NB
accept_Blk
accept_NB
set_NB
set_so_linger
inet_aton
inet_ntoa
sockaddr_in
sockaddr_un
dyn_bind
);
$sock = open_UDP();
$sock = open_udpNB();
DEPRECATED $sock = bind2pp($sock,$port_path,$netaddr);
$listener = open_Listen($port_path,$netaddr);
$listener = open_listenNB($port_path,$netaddr);
$rv = set_NB(*SOCK);
$rv = set_so_linger(*HANDLE,$seconds);
$client = connectBlk($port_path,$netaddr);
$client = connect_NB($port_path,$netaddr);
($sock,$netaddr) = accept_Blk(*SERVER);
($sock,$netaddr) = accept_NB(*SERVER);
$netaddr = inet_aton($dot_quad);
$dot_quad = inet_ntoa($netaddr);
$sin = sockaddr_in($port,$netaddr);
($port,$netaddr) = sockaddr_in($sin);
$sun = sockaddr_un($path);
($path) = sockaddr_un($sun);
$port = dyn_bind($sock,$iaddr);
DESCRIPTION
Net::NBsocket provides a wrapper for Socket to supply Non-Blocking sockets of various flavors;
$netaddr = inet_aton($dot_quad);
$dot_quad = inet_ntoa($netaddr);
$sin = sockaddr_in($port,$netaddr);
($port,$netaddr) = sockaddr_in($sin);
$sun = sockaddr_un($path);
($path) = sockaddr_un($sun);
All above exported from Socket in the EXPORT_OK array.
$sock = open_UDP();
Open an unbound UDP socket as below.
$sock = open_udpNB();
Open and return an unbound non-blocking UDP socket object
input: none returns: pointer to socket object or undef on failure
DEPRECATED $sock=bind2pp($sock,$port_path,$netaddr);
Bind to $port_path and an optional IPv4 bind address as returned by inet_aton (defaults to INADDR_ANY).
input: port or unix domain socket path, [optional] bind address returns: socket on sucess, else undef;
Author's note: This function was not well thought out and is now deprecated. It may be removed in future versions and is no longer in the EXPORT_OK array though it is still in the module and may be accessed with Net::NBsocket::bind2pp();
$listener = open_Listen($port_path,$netaddr);
Open a blocking TCP listner as below.
$listener = open_listenNB($port_path,$netaddr);
Open and return a non-blocking TCP listener bound to $port_path and an optional IPv4 bind address as returned by inet_aton (defaults to INADDR_ANY).
Opens a unix-domain socket if port_path is a path instead of a number.
The user must set the appropriate UMASK prior to calling this routine.
input: port or unix domain socket path, [optional] bind address returns: pointer to listening socket object or undef on failure
$rv = set_NB(*SOCK);
Set a socket to Non-Blocking mode
input: SOCK object pointer returns: true on success or undef on failure
$rv = set_so_linger(*HANDLE,$seconds);
Set SO_LINGER on top level socket input: *HANDLE, seconds returns: true = success, false = fail
$client = connectBlk($port_path,$netaddr);
Begin a blocking TCP connection as below.
$client = connect_NB($port_path,$netaddr);
Begin a non-blocking TCP connection to the host designated by $netaddr on $port_path, or to the unix domain socket designated by the path in $port_path. $netaddr is unused for unix domain sockets.
input: port number or unix domain socket path, netaddr as returned by inet_aton returns: socket object or undef on failure
($sock,$netaddr) = accept_Blk(*SERVER);
Accept a connection and return a BLOCKING socket as below.
($sock,$netaddr) = accept_NB(*SERVER);
Accept a connection from a remote client, return a non-blocking socket and the network address of the remote host as returned by inet_aton or the unix domain socket path if PF_INET or PF_UNIX respectively.
input: listening socket object returns: client socket object, client packed netaddr or unix domain socket path or an emtpy array on failure
$port = dyn_bind($sock,$iaddr);
Attempt to bind a socket to the IP address and randomly assigned port number, in the range 49152 through 65535. Fails after 100 attempts
input: socket iaddr as returned by sockaddr_in returns: port number or undef
DEPENDENCIES
POSIX
Socket
EXPORT_OK
open_UDP
open_udpNB
open_Listen
open_listenNB
connectBlk
connect_NB
accept_Blk
accept_NB
set_NB
set_so_linger
inet_aton
inet_ntoa
sockaddr_in
sockaddr_un
dyn_bind
AUTHOR
Michael Robinton, michael@bizsystems.com
COPYRIGHT 2004 - 2011
Michael Robinton
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of either:
a) the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any
later version, or
b) the "Artistic License" which comes with this distribution.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the Artistic License for more details.
You should have received a copy of the Artistic License with this distribution, in the file named "Artistic". If not, I'll be glad to provide one.
You should also have received a copy of the GNU General Public License along with this program in the file named "Copying". If not, write to the
Free Software Foundation, Inc.
59 Temple Place, Suite 330
Boston, MA 02111-1307, USA
or visit their web page on the internet at:
http://www.gnu.org/copyleft/gpl.html.
SEE ALSO
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 234:
Expected '=item *'