net_sample
Version, currently 0.2.43 versions
- 0.2.5latestSep 30, 2020
- 0.2.4not indexedNov 1, 2020
- 0.2.3not indexedNov 1, 2020
github.com/PercussiveElbow/net_sample.cr
No description declared in shard.yml.
Nothing has been indexed for 0.2.4 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
net_sample:
github: PercussiveElbow/net_sample.cr
version: ~> 0.2.4Then run:
shards installshard.yml
No shard.yml has been indexed for 0.2.4. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
Network programing samples for the Crystal language
This shard includes following sample codes.
-
Gets following informations of the ethernet interfaces.
- hardware address a.k.a. MAC address or phisical address
- IPv4 address
- IPv6 address
Tested on gnu(CentOS8)/musl(official alpine linux image) linux and and BSD(Mac OS 10.14).
-
pinglike commandSends ICMP ECHO request and receive its REPLY.
NOTE: Included codes are not practical but only samples.
Installation
- Add the dependency to your
shard.yml
dependencies:
net_sample:
github: arcage/net_sample.cr
- Run
shards install
Usage
require "net_sample"
# get interface names
NetSample::NIC.ifnames
#=> ["lo0", "eth1"]
puts eth1 = NetSample::NIC["eth1"]
#=> <NIC: "eth1", inaddr: 192.0.2.100, in6addr: fe80::1234:abcd, hwaddr: aa:bb:cc:dd:ee:ff>
# ping like command(require root privirage)
NetSample::Ping.command("192.0.2.1")
#=>
# PING 192.0.2.1: 56 data bytes
# 64 bytes from 192.0.2.1: icmp_seq=0 ttl=253 time=1.903 ms
# 64 bytes from 192.0.2.1: icmp_seq=1 ttl=253 time=1.466 ms
# 64 bytes from 192.0.2.1: icmp_seq=2 ttl=253 time=1.355 ms
# 64 bytes from 192.0.2.1: icmp_seq=3 ttl=253 time=2.115 ms
# 64 bytes from 192.0.2.1: icmp_seq=4 ttl=253 time=2.074 ms
#
# --- 192.0.2.1 ping statistics ---
# 5 packets transmitted, 5 packets received, 0% packet loss
# round-trip min/avg/max/stddev = 1.355/1.783/2.115/0.346 ms
Contributors
- ʕ·ᴥ·ʔAKJ - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.2.4- Tagged
- Nov 1, 2020
- Commit
4ce05c1aba25- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/PercussiveElbow/net_sample.cr
Metadata
- Created
- Aug 16, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 3