This commit is contained in:
suyl
2021-06-15 15:57:07 +08:00
parent 14ef7cb40a
commit 5cafeb9a50

30
main.go
View File

@@ -144,26 +144,26 @@ func main() {
http.ListenAndServe("0.0.0.0:6060", nil) http.ListenAndServe("0.0.0.0:6060", nil)
} }
}() }()
l, err := net.Listen("tcp", "print.jxcs.net:8000") //l, err := net.Listen("tcp", "print.jxcs.net:8000")
if err != nil { //if err != nil {
fmt.Println("listen error:", err) // fmt.Println("listen error:", err)
return // return
} //}
for { //for {
c, err := l.Accept() // c, err := l.Accept()
if err != nil { // if err != nil {
fmt.Println("accept error:", err) // fmt.Println("accept error:", err)
break // break
} // }
globals.SugarLogger.Debugf("tcp socket:", utils.Format4Output(c, true)) // globals.SugarLogger.Debugf("tcp socket:", utils.Format4Output(c, true))
go handleConn(c) // go handleConn(c)
} //}
beego.Run() beego.Run()
} }
} }
func handleConn(c net.Conn) { func handleConn(c net.Conn) {
//defer c.Close() defer c.Close()
for { for {
globals.SugarLogger.Debugf("tcp socket read:", utils.Format4Output(c, true)) globals.SugarLogger.Debugf("tcp socket read:", utils.Format4Output(c, true))
} }