master
sre 4 years ago
parent 9c972120ef
commit 6c76bc7e07

@ -5,14 +5,22 @@ import (
"os" "os"
"os/signal" "os/signal"
"testing" "testing"
"time"
) )
func TestSign(tt *testing.T) { func TestSign(tt *testing.T) {
c := make(chan os.Signal, 1) c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill) for {
select {
s := <-c case s := <-c:
fmt.Println("Got signal:", s) 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 TestPing(tt *testing.T) { func TestPing(tt *testing.T) {
//if len(os.Args) < 3 { //if len(os.Args) < 3 {

@ -22,11 +22,12 @@ pong www.baidu.com 443 -t 1 -k udp
pong -a www.baidu.com -p 443 -k tcp -t 3 pong -a www.baidu.com -p 443 -k tcp -t 3
` `
func main2() { func main() {
c := make(chan os.Signal, 1) c := make(chan os.Signal, 1)
for { for {
select { select {
case s := <-c: case s := <-c:
fmt.Println("ctc")
signal.Notify(c, os.Interrupt, os.Kill) signal.Notify(c, os.Interrupt, os.Kill)
fmt.Println("Got signal:", s) fmt.Println("Got signal:", s)
os.Exit(0) os.Exit(0)
@ -37,7 +38,7 @@ func main2() {
} }
} }
func main() { func main3() {
address := flag.String("a", "", "domain or ip address") address := flag.String("a", "", "domain or ip address")
port := flag.Int("p", 0, "port") port := flag.Int("p", 0, "port")
protocol := flag.String("k", "tcp", "protocol kind") protocol := flag.String("k", "tcp", "protocol kind")

Loading…
Cancel
Save