NAME

Net::Connection::Linux_ss - Creates Net::Connection objects using ss on Linux.

VERSION

Version 0.0.1

SYNOPSIS

use Net::Connection::Linux_ss;

my @objects;
eval{ @objects=&ss_to_nc_objects; };

# this time don't resolve ports or ptrs
my $args={
     ports=>0,
     ptrs=>0,
};
eval{ @objects=&ss_to_nc_objects( $args ); };

REQUIREMENTS

This parses the output of 'ss -p4an' and 'ss -p6an', the ss from iproute2.

Process information beyond what ss itself reports is gathered from Proc::ProcessTable and /proc.

SUBROUTINES

ss_to_nc_objects

This calls 'ss -p4an 2> /dev/null' and 'ss -p6an 2> /dev/null', parses their output, and returns an array of Net::Connection objects.

Upon error, this will die.

A single socket may be held open by more than one process, which ss reports as several entries in the process column of the one line. One object is returned per process in that column, mirroring what lsof would print, so those sockets appear more than once in the returned array.

args hash

ports

Attempt to resolve the port names.

Defaults to 1.

This value is a Perl boolean.

ptrs

Attempt to resolve the PTRs.

Defaults to 1.

This value is a Perl boolean.

uid_resolve

Attempt to resolve the UID to a username.

The UID itself is not something ss reports, so it is taken from the owner of /proc/<pid>, meaning it is only available when this module is the one calling ss.

Defaults to 1.

This value is a Perl boolean.

proc_info

Use Proc::ProcessTable and /proc to fill in additional info.

This is what fills in proc, wchan, pctcpu, pctmem, and pid_start. Without it, proc is still set, but to the process name ss prints, which is truncated to fifteen characters.

This is incompatible with the string options.

This defaults to true if neither of the string options is specified.

This value is a Perl boolean.

ipv4

Call 'ss -p4an' and include the IPv4 sockets.

Defaults to 1.

This value is a Perl boolean.

ipv6

Call 'ss -p6an' and include the IPv6 sockets.

Defaults to 1.

This value is a Perl boolean.

ipv4_string

If this is specified, it parses the string as the output of 'ss -p4an' instead of calling ss.

ipv6_string

If this is specified, it parses the string as the output of 'ss -p6an' instead of calling ss.

If either of the string options is specified, ss is not called at all, so specifying just one of the two parses just that one.

If running this on anything other than Linux without passing one of these, it will die.

zombie_skip

This skips sockets that are not associated with any process, which is what the ones with an empty process column are.

When these are not skipped, the resulting objects have the PID and UID left undefined, as Net::Connection requires those two to be numeric when they are defined.

This defaults to 1.

The value taken is a Perl boolean.

AUTHOR

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

BUGS

Please report any bugs or feature requests to bug-net-connection-linux_ss at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Connection-Linux_ss. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

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

perldoc Net::Connection::Linux_ss

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

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

This is free software, licensed under:

The GNU Lesser General Public License, Version 2.1, February 1999