|
NAMENet::Connection - Represents a network connection as a object.VERSIONVersion 0.2.0SYNOPSISuse Net::Connection; #create a hash ref with the desired values my $args={ 'foreign_host' => '1.2.3.4', 'local_host' => '4.3.2.1', 'foreign_port' => '22', 'local_port' => '11132', 'sendq' => '1', 'recvq' => '0', 'pid' => '34342', 'uid' => '1000', 'state' => 'ESTABLISHED', 'proto' => 'tcp4' }; # create the new object using the hash ref my $conn=Net::Connection->new( $args ); # the same thing, but this time resolve the UID to a username $args->{'uid_resolve'}='1'; $conn=Net::Connection->new( $args ); # now with PTR lookup $args->{'ptrs'}='1'; $conn=Net::Connection->new( $args ); # prints a bit of the connection information... print "L Host:".$conn->local_host."\n". "L Port:".$conn->local_host."\n". "F Host:".$conn->foreign_host."\n". "F Port:".$conn->foreign_host."\n"; MethodsnewThis initiates a new connection object.One argument is taken is taken and it is a hash reference. The minimum number of arguements is as below. local_host local_port foreign_host foreign_port proto state keys foreign_host The local host of the connection. This can either be a IP or hostname. Max utility is achieved via a IP though as that allows PTR lookup to be done. If appears to be a hostname, it is copied to local_ptr and even if asked to resolve PTRs it won't attempt to. foreign_port This is the foreign port of the connection. For best utility, using numeric here is best. If ports is true it will attempt to resolve it, including reverse resolving if it is a port name instead. If ports is false or not set and this value is non-numeric, it will be copied to foreign_port_name. foreign_port_name This is the name of foreign port, if one exists in the service records. foreign_ptr This is the PTR address for foreign_host. If ptrs is not true and foreign_host appears to be a hostname, then it is set to the same as foreign_host. local_port This is the local port of the connection. For best utility, using numeric here is best. If ports is true it will attempt to resolve it, including reverse resolving if it is a port name instead. If ports is false or not set and this value is non-numeric, it will be copied to local_port_name. local_port_name This is the name of local port, if one exists in the service records. local_ptr This is the PTR address for local_host. If ptrs is not true and local_host appears to be a hostname, then it is set to the same as local_host. pctcpuPercent of CPU usage by the PID for this connection.pctmemPercent of memory usage by the PID for this connection.pid This is the pid for a connection. If defined, it needs to be numeric. pid_start The start time in seconds of the PID for the connection. ports If true, it will attempt to resolve the port names. proto This is the protocol type. This needs to be defined, but unfortunately no real checking is done as of currently as various OSes uses varrying capitalizations and slightly different forms of TCP, TCP4, tcp4, tcpv4, and the like. proc Either the command line or fname if that is blank for the PID. ptrs If is true, then attempt to look up the PTRs for the hosts. recvq This is the recieve queue size. If set, it must be numeric. sendq This is the send queue size. If set, it must be numeric. state This is the current state of the connection. This needs to be defined, but unfortunately no real checking is done as of currently as there are minor naming differences between OSes as well as some including states that are not found in others. uid The UID is the of the user the has the connection open. This must be numeric. If uid_resolve is set to true then the UID will be resolved and stored in username. If this is not defined, uid_resolve is true, and username is defined then it will attempt to resolve the UID from the username. uid_resolve If set to true and uid is given, then a attempt will be made to resolve the UID to a username. username This is the username for a connection. If uid_resolve is true and uid is defined, then this will attempt to be automatically contemplated. If uid_resolve is true and uid is defined, then this will attempt to be automatically contemplated. wchan The current wait channel for the PID of the connection in question. foreign_hostReturns the foreign host.my $f_host=$conn->foreign_host; foreign_portThis returns the foreign port.my $f_port=$conn->foreign_port; foreign_port_nameThis returns the foreign port name.This may potentially return undef if one is not set/unknown. my $f_port=$conn->foreign_port; foreign_ptrThis returns the PTR for the foreign host.If one was not supplied or if it could not be found if resolving was enabled then undef will be returned. my $f_ptr=$conn->foreign_ptr; local_hostReturns the local host.my $l_host=$conn->local_host; local_portThis returns the local port.my $l_port=$conn->local_port; local_port_nameThis returns the local port name.This may potentially return undef if one is not set/unknown. my $l_port=$conn->local_port; local_ptrThis returns the PTR for the local host.If one was not supplied or if it could not be found if resolving was enabled then undef will be returned. my $l_ptr=$conn->local_ptr; pctcpuReturns the percent of memory in use by the process that has connection.This may not be if it was not set. Please see new for more information. my $pctcpu=$conn->pctcpu; pctmemReturns the percent of memory in use by the process that has connection.This may not be if it was not set. Please see new for more information. my $pctmem=$conn->pctmem; pidThis returns the pid of a connection.This may return undef. my $pid=$conn->pid; procReturns the command line or fname for the process that has the connection.This may not be if it was not set. Please see new for more information. my $proc=$conn->proc; protoReturns the protocol in use by the connection.Please note this value with vary slightly between OSes. my $proto=$conn->proto; recvqReturns the size of the recieve queue the connection.This may return undef. my $recvq=$conn->recvq; sendqReturns the size of the send queue the connection.This may return undef. my $sendq=$conn->sendq; stateReturns the state the connection is currently in.Please note this value with vary slightly between OSes. my $state=$conn->state; uidReturns the UID that has the connection.This may not be if it was not set. Please see new for more information. my $uid=$conn->uid; usernameReturns the username that has the connection.This may not be if it was not set. Please see new for more information. my $username=$conn->username; wchanReturns the wchan for the process that has the connection.This may not be if it was not set. Please see new for more information. my $wchan=$conn->wchan; AUTHORZane C. Bowers-Hadley, "<vvelox at vvelox.net>"BUGSPlease report any bugs or feature requests to "bug-net-connection at rt.cpan.org", or through the web interface at <https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Connection>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.SUPPORTYou can find documentation for this module with the perldoc command.perldoc Net::Connection You can also look for information at:
ACKNOWLEDGEMENTSLICENSE AND COPYRIGHTThis software is Copyright (c) 2019 by Zane C. Bowers-Hadley.This is free software, licensed under: The Artistic License 2.0 (GPL Compatible)
Visit the GSP FreeBSD Man Page Interface. |