GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Net::Connection(3) User Contributed Perl Documentation Net::Connection(3)

Net::Connection - Represents a network connection as a object.

Version 0.2.0

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

This 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.

Percent of CPU usage by the PID for this connection.

Percent 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.

Returns the foreign host.

    my $f_host=$conn->foreign_host;

This returns the foreign port.

    my $f_port=$conn->foreign_port;

This returns the foreign port name.

This may potentially return undef if one is not set/unknown.

    my $f_port=$conn->foreign_port;

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

Returns the local host.

    my $l_host=$conn->local_host;

This returns the local port.

    my $l_port=$conn->local_port;

This returns the local port name.

This may potentially return undef if one is not set/unknown.

    my $l_port=$conn->local_port;

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

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

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

This returns the pid of a connection.

This may return undef.

    my $pid=$conn->pid;

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

Returns the protocol in use by the connection.

Please note this value with vary slightly between OSes.

    my $proto=$conn->proto;

Returns the size of the recieve queue the connection.

This may return undef.

    my $recvq=$conn->recvq;

Returns the size of the send queue the connection.

This may return undef.

    my $sendq=$conn->sendq;

Returns the state the connection is currently in.

Please note this value with vary slightly between OSes.

    my $state=$conn->state;

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

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

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

Zane C. Bowers-Hadley, "<vvelox at vvelox.net>"

Please 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.

You can find documentation for this module with the perldoc command.

    perldoc Net::Connection

You can also look for information at:

  • RT: CPAN's request tracker (report bugs here)

    <https://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Connection>

  • AnnoCPAN: Annotated CPAN documentation

    <http://annocpan.org/dist/Net-Connection>

  • CPAN Ratings

    <https://cpanratings.perl.org/d/Net-Connection>

  • Search CPAN

    <https://metacpan.org/release/Net-Connection>

  • Repository

    <http://gitea.eesdp.org/vvelox/Net-Connection>

This software is Copyright (c) 2019 by Zane C. Bowers-Hadley.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)
2019-08-11 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.