|
|
|
|
@ -8,6 +8,7 @@ import (
|
|
|
|
|
"pong/dial"
|
|
|
|
|
"pong/goping"
|
|
|
|
|
"strconv"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 定义命令行参数对应的变量,这三个变量都是指针类型
|
|
|
|
|
@ -21,14 +22,22 @@ pong www.baidu.com 443 -t 1 -k udp
|
|
|
|
|
pong -a www.baidu.com -p 443 -k tcp -t 3
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
func main2() {
|
|
|
|
|
c := make(chan os.Signal, 1)
|
|
|
|
|
signal.Notify(c, os.Interrupt, os.Kill)
|
|
|
|
|
|
|
|
|
|
s := <-c
|
|
|
|
|
fmt.Println("Got signal:", s)
|
|
|
|
|
for {
|
|
|
|
|
select {
|
|
|
|
|
case s := <-c:
|
|
|
|
|
signal.Notify(c, os.Interrupt, os.Kill)
|
|
|
|
|
fmt.Println("Got signal:", s)
|
|
|
|
|
os.Exit(0)
|
|
|
|
|
default:
|
|
|
|
|
fmt.Println("okok")
|
|
|
|
|
time.Sleep(time.Second * 1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
func main1() {
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
address := flag.String("a", "", "domain or ip address")
|
|
|
|
|
port := flag.Int("p", 0, "port")
|
|
|
|
|
protocol := flag.String("k", "tcp", "protocol kind")
|
|
|
|
|
|