tags:

views:

96

answers:

2

Is it possible to implement an ICMP ping in Go? The alternative is to fork a 'ping' process, but I'd rather write it in Go.

A: 

Go has a foreign function interface which allows you to call C functions from Go. Using this method, you can call the socket system functions to open a (raw) socket and send ICMP packets.

Greg Hewgill
+2  A: 

Currently, the ICMP Echo (Ping) function isn't supported in the Go net package.

There's no support for sending ICMP echo requests. You'd have to add support to package net. ping

peterSO
Now (since late May 2010), Go supports raw sockets(See the net.IPConn type) - meaning you can implement ping yourself - and there's a ping example at https://code.google.com/p/go/source/browse/src/pkg/net/ipraw_test.go
nos