class

Ping::ICMPPinger

Inherits Reference < Object

Native Crystal ICMP ping using SOCK_DGRAM + IPPROTO_ICMP. On macOS regular users can open ICMP datagram sockets without root. Each ping session runs in a dedicated OS thread (Fiber::ExecutionContext::Isolated) so it doesn't block the UIng event loop on the main thread.

Constants

DEFAULT_INTERVAL = 1.second
ECHO_REQUEST = 8_u8
HEADER_SIZE = 8
IPPROTO_ICMP = Socket::Protocol.new(1)
PACKET_SIZE = HEADER_SIZE + PAYLOAD.bytesize
PAYLOAD = "CrystalPingMon "
TIMEOUT = 2.seconds

Constructors

new(on_log : Proc(String, Nil), on_sample : Proc(SampleInput, Nil), on_finished : Proc(String | Nil, Nil), interval : Time::Span = DEFAULT_INTERVAL)
Source

Class methods

start_error_message(message : String | Nil) : String | Nil
Source

Instance methods

running?
Source
start(host : String) : Nil
Source
stop
Source
wait_for_completion
Source

Nested types