class
Miniss::Sockets
- Miniss::Sockets
- Reference
- Object
Overview
Sockets object has properties containing arrays of Sockets from the parsed
sockets files of a base folder (default: /proc/net).
Example:
sockets = Miniss::Sockets.new # parse `/proc/net`
sockets = Miniss::Sockets.new("/proc/1234/net") # parse the net folder of a given process
sockets.tcpv4.each do |so|
puts "#{so.laddr} <-> #{so.raddr}"
end
Defined in:
miniss/addr.crConstructors
-
.new(base : String = "/proc/net")
Initialize
Socketsclass.
Instance Method Summary
-
#all
Returns all sockets
-
#base : String
Base folder containing the sockets files (
tcp,tcp6,udp,udp6). -
#parse_tcpv4 : Array(Socket)
Parse all IPv4 TCP sockets from
<base>/tcp(e.g. -
#parse_tcpv6 : Array(Socket)
Parse all IPv6 TCP sockets from
<base>/tcp6(e.g. -
#parse_udpv4 : Array(Socket)
Parse all IPv4 UDP sockets from
<base>/udp(e.g. -
#parse_udpv6 : Array(Socket)
Parse all IPv6 UDP sockets from
<base>/udp6(e.g. -
#tcpv4 : Array(Socket)
Returns all IPv4 TCP sockets
-
#tcpv6 : Array(Socket)
Returns all IPv6 TCP sockets
-
#udpv4 : Array(Socket)
Returns all IPv4 UDP sockets
-
#udpv6 : Array(Socket)
Returns all IPv6 UDP sockets
Constructor Detail
Initialize Sockets class.
By default sockets files are parsed from /proc/net but another base folder can be set, e.g. /proc/1234/net to list the sockets of a given process ID.
NOTE Missing or unreadable sockets files (not every process exposes all of tcp, tcp6, udp, udp6) are silently skipped.
Instance Method Detail
Parse all IPv4 TCP sockets from <base>/tcp (e.g. /proc/net/tcp).
Parse all IPv6 TCP sockets from <base>/tcp6 (e.g. /proc/net/tcp6).
Parse all IPv4 UDP sockets from <base>/udp (e.g. /proc/net/udp).
Parse all IPv6 UDP sockets from <base>/udp6 (e.g. /proc/net/udp6).