Documentation ¶
Overview ¶
Package ping provides primitives to ping network endpoints.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pinger ¶
type Pinger interface { // Ping sends single packet and waits for a limited time for reply. // Returned values are whether reply was received in time, measured // round trip time, number of bytes in received payload and error. It // only returns errors on non-recoverable errors, if it does not receive // reply for implementation-specific time limit, it reports false with // nil error which should be interpreted as timeout. Ping() (ok bool, info RoundInfo, err error) // PeerIP returns IP address Ping sends packets to PeerIP() net.IP // Summary returns statistics collected from multiple Ping calls. It is // usually called after multiple Ping calls and followed by Close call. Stat() Summary // Close frees resources used by Pinger (network sockets, etc.) Other // methods should not be called after Close. Close() error }
Pinger is used to ping remote endpoints.
func NewICMP ¶
NewICMP returns new Pinger which pings addr using IPv4 ICMP echo messages. addr should either be an IPv4 or hostname that resolves to IPv4. If addr resolves to multiple addresses, the first IPv4 record is used.
Currently this only works on macOS or Linux; if on Linux you get permission denied error, ensure that sysctl net.ipv4.ping_group_range includes your group id.
Click to show internal directories.
Click to hide internal directories.