@@ -236,6 +236,7 @@ Go语言中通过net包中的`DialTCP`函数来建立一个TCP连接,并返回
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -267,7 +268,7 @@ Go语言中通过net包中的`DialTCP`函数来建立一个TCP连接,并返回
|
|||||||
|
|
||||||
if read_len == 0 {
|
if read_len == 0 {
|
||||||
break // connection already closed by client
|
break // connection already closed by client
|
||||||
} else if string(request) == "timestamp" {
|
} else if strings.TrimSpace(string(request[:read_len])) == "timestamp" {
|
||||||
daytime := strconv.FormatInt(time.Now().Unix(), 10)
|
daytime := strconv.FormatInt(time.Now().Unix(), 10)
|
||||||
conn.Write([]byte(daytime))
|
conn.Write([]byte(daytime))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user