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


[View source]

Instance Method Detail

def ipv : UInt8 #

IP version (v4, v6).

Accepts values: 4_u8, 6_u8.


[View source]
def laddr : String #

Local address (IP + port).


[View source]
def laddr=(laddr : String) #

Local address (IP + port).


[View source]
def parse_line(line : String) : Nil #

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


[View source]
def raddr : String #

Remote address (IP + port).


[View source]
def raddr=(raddr : String) #

Remote address (IP + port).


[View source]
def state : String #

Socket state cf. Miniss::TCP_STATES.


[View source]
def state=(state : String) #

Socket state cf. Miniss::TCP_STATES.


[View source]
def type : Symbol #

Socket type (TCP, UDP).

Accepts values: :tcp, :udp.


[View source]
def uid : UInt32 #

Process owner user ID.


[View source]
def uid=(uid : UInt32) #

Process owner user ID.


[View source]
def uname : String #

Process owner user name.


[View source]
def uname=(uname : String) #

Process owner user name.


[View source]