1
0
mirror of https://github.com/taigrr/go-fastping synced 2025-01-18 05:03:15 -08:00

Fix documents

This commit is contained in:
Tatsushi Demachi 2014-08-03 18:23:10 +09:00
parent 9bc45ffa9d
commit f930d86dae
2 changed files with 28 additions and 6 deletions

View File

@ -24,13 +24,24 @@ if err != nil {
os.Exit(1) os.Exit(1)
} }
p.AddIPAddr(ra) p.AddIPAddr(ra)
p.AddHandler("receive", func(addr *net.IPAddr, rtt time.Duration) { err = p.AddHandler("receive", func(addr *net.IPAddr, rtt time.Duration) {
fmt.Printf("IP Addr: %s receive, RTT: %v\n", addr.String(), rtt) fmt.Printf("IP Addr: %s receive, RTT: %v\n", addr.String(), rtt)
}) })
p.AddHandler("idle", func() { if err != nil {
fmt.Println(err)
os.Exit(1)
}
err = p.AddHandler("idle", func() {
fmt.Println("finish") fmt.Println("finish")
}) })
p.Run() if err != nil {
fmt.Println(err)
os.Exit(1)
}
err = p.Run()
if err != nil {
fmt.Println(err)
}
``` ```
It sends an ICMP packet and wait a response. If it receives a response, it It sends an ICMP packet and wait a response. If it receives a response, it

View File

@ -15,13 +15,24 @@
// os.Exit(1) // os.Exit(1)
// } // }
// p.AddIPAddr(ra) // p.AddIPAddr(ra)
// p.AddHandler("receive", func(addr *net.IPAddr, rtt time.Duration) { // err = p.AddHandler("receive", func(addr *net.IPAddr, rtt time.Duration) {
// fmt.Printf("IP Addr: %s receive, RTT: %v\n", addr.String(), rtt) // fmt.Printf("IP Addr: %s receive, RTT: %v\n", addr.String(), rtt)
// }) // })
// p.AddHandler("idle", func() { // if err != nil {
// fmt.Println(err)
// os.Exit(1)
// }
// err = p.AddHandler("idle", func() {
// fmt.Println("finish") // fmt.Println("finish")
// }) // })
// p.Run() // if err != nil {
// fmt.Println(err)
// os.Exit(1)
// }
// err = p.Run()
// if err != nil {
// fmt.Println(err)
// }
// //
// It sends an ICMP packet and wait a response. If it receives a response, // It sends an ICMP packet and wait a response. If it receives a response,
// it calls "receive" callback. After that, MaxRTT time passed, it calls // it calls "receive" callback. After that, MaxRTT time passed, it calls