Reputation: 1570
How to send a ICMPv6 ping request with Racket or Scheme?
There is https://docs.racket-lang.org/net/index.html, but it has almost nothing about the internet level protocols.
There is https://docs.racket-lang.org/net2/index.html, but it seems unfinished or abandoned.
Upvotes: 1
Views: 114
Reputation: 16250
Racket supplies functions to work with the transport layer protocols TCP and UDP on all the platforms Racket supports (e.g. *nix, macOS, Windows).
But as far as I know it does not for lower network layer functionality such as ICMP (for IPv4 or IPv6).
Racket does supply an FFI, through which you could call the appropriate OS-specific functions that might let you do this. However, depending on what you want to accomplish, it might be simpler to use process
to run a command like ping
-- then read-line
the Racket input port piped from the subprocess standard output, and parse that to get the information you need. (If you have questions about the details of using process
, that would probably make for a good, separate question to post here.)
Update: Instead of process
you could probably just use system
:
#lang racket/base
(require racket/port
racket/system)
(with-output-to-string
(lambda () (system "ping -c 1 127.0.0.1")))
That returns a string like:
"PING 127.0.0.1 (127.0.0.1): 56 data bytes\n64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.068 ms\n\n--- 127.0.0.1 ping statistics ---\n1 packets transmitted, 1 packets received, 0.0% packet loss\nround-trip min/avg/max/stddev = 0.068/0.068/0.068/0.000 ms\n"
Upvotes: 3