diff --git a/server/src/__debug_bin b/server/src/__debug_bin new file mode 100755 index 0000000..659c553 Binary files /dev/null and b/server/src/__debug_bin differ diff --git a/server/src/main.go b/server/src/main.go index ff63dbd..3b6d917 100644 --- a/server/src/main.go +++ b/server/src/main.go @@ -86,9 +86,21 @@ func main() { } defer outconn.Close() recvBuf := make([]byte, 1024) - outconn.Write([]byte("showtime")) - outconn.Read(recvBuf) - conn.Write(recvBuf) + _, err2 := outconn.Write([]byte("showtime")) + if err2 != nil { + fmt.Println(err) + os.Exit(1) + } + _, err3 := outconn.Read(recvBuf) + if err3 != nil { + fmt.Println(err) + os.Exit(1) + } + _, err4 := conn.Write(recvBuf) + if err4 != nil { + fmt.Println(err) + os.Exit(1) + } } } if resp == "quit" { diff --git a/server/src/scaner.go b/server/src/scaner.go index 19d3ddd..1a4dbef 100644 --- a/server/src/scaner.go +++ b/server/src/scaner.go @@ -17,20 +17,20 @@ func scan() []string { ipv4 = ipv4.To4() ipv4 = ipv4.Mask(ipv4.DefaultMask()) ipv4[3]++ - // for i := 1; i < 2; i++ { - // _, dialErr := net.DialTimeout("tcp", ipv4.String()+":8081", time.Duration(1)*time.Second) - _, dialErr := net.DialTimeout("tcp", "192.168.0.100:8081", time.Duration(1)*time.Second) - if dialErr != nil { - // fmt.Println("Cannot connect to " + ipv4.String()) - fmt.Println("Cannot connect to " + "192.168.0.100:8081") - } else { - // fmt.Println("Response from " + ipv4.String()) - fmt.Println("Response from " + "192.168.0.100:8081") - // information = append(information, ipv4.String()) - information = append(information, "192.168.0.100:8081") + for i := 1; i < 2; i++ { + _, dialErr := net.DialTimeout("tcp", ipv4.String()+":8081", time.Duration(1)*time.Second) + // _, dialErr := net.DialTimeout("tcp", "192.168.0.100:8081", time.Duration(1)*time.Second) + if dialErr != nil { + fmt.Println("Cannot connect to " + ipv4.String()) + // fmt.Println("Cannot connect to " + "192.168.0.100:8081") + } else { + fmt.Println("Response from " + ipv4.String()) + // fmt.Println("Response from " + "192.168.0.100:8081") + information = append(information, ipv4.String()) + // information = append(information, "192.168.0.100:8081") + } + ipv4[3]++ } - ipv4[3]++ - // } } } }