项目作者: arcage

项目描述 :
Minimum ping command clone by Crystal langage.
高级语言: Crystal
项目地址: git://github.com/arcage/ping.cr.git
创建时间: 2018-11-21T09:58:41Z
项目社区:https://github.com/arcage/ping.cr

开源协议:MIT License

下载


Ping.cr

The minimum ICMP echo handling shard.

This shard is only an experiment to use the raw socket in the Crystal language.

Installation

  1. Add the dependency to your shard.yml:
    1. dependencies:
    2. ping:
    3. github: arcage/ping.cr
  2. Run shards install

Usage

  1. # src/ping_command.cr
  2. require "ping"
  3. Ping.command(ARGV.shift)
  1. $ sudo crystal src/ping_command.cr 192.0.2.1
  2. PING 192.0.2.1: 56 data bytes
  3. 64 bytes from 192.0.2.1: icmp_seq=0 ttl=253 time=1.903 ms
  4. 64 bytes from 192.0.2.1: icmp_seq=1 ttl=253 time=1.466 ms
  5. 64 bytes from 192.0.2.1: icmp_seq=2 ttl=253 time=1.355 ms
  6. 64 bytes from 192.0.2.1: icmp_seq=3 ttl=253 time=2.115 ms
  7. 64 bytes from 192.0.2.1: icmp_seq=4 ttl=253 time=2.074 ms
  8. --- 192.0.2.1 ping statistics ---
  9. 5 packets transmitted, 5 packets received, 0% packet loss
  10. round-trip min/avg/max/stddev = 1.355/1.783/2.115/0.346 ms

NOTE: Because this shard use RAW SOCKET, you need sudo when execute the program with this shard.

Contributors