class Miniss::Socket

Overview

Socket object, having several properties.

Example:

so = Miniss::Socket.new(:tcp, 4_u8)
line = File.readlines("/proc/net/tcp")[1]
so.parse_line(line)
so.laddr # => "127.0.0.53:53"
so.state # => "LISTEN"
so.uname # => "systemd-resolve"
so.uid   # => 980

Defined in:

miniss/addr.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(type : Symbol, ipv : UInt8) #

Initialize Socket class.

Choose the type of socket. Arguments: type (cf. #type), ipv (cf. #ipv).


Instance Method Detail

def ipv : UInt8 #

IP version (v4, v6).

Accepts values: 4_u8, 6_u8.


def laddr : String #

Local address (IP + port).


def laddr=(laddr : String) #

Local address (IP + port).


def parse_line(line : String) : Nil #

Parse a socket line from /proc/net/XXX and set Socket instance properties.


def raddr : String #

Remote address (IP + port).


def raddr=(raddr : String) #

Remote address (IP + port).


def state : String #

Socket state cf. Miniss::TCP_STATES.


def state=(state : String) #

Socket state cf. Miniss::TCP_STATES.


def type : Symbol #

Socket type (TCP, UDP).

Accepts values: :tcp, :udp.


def uid : UInt32 #

Process owner user ID.


def uid=(uid : UInt32) #

Process owner user ID.


def uname : String #

Process owner user name.


def uname=(uname : String) #

Process owner user name.