This commit is contained in:
suyl
2021-08-10 10:32:02 +08:00
parent 4ad32dc2b7
commit 1947db34c0

View File

@@ -7,6 +7,7 @@ import (
"net" "net"
"os" "os"
"regexp" "regexp"
"strconv"
"strings" "strings"
"time" "time"
@@ -1989,13 +1990,29 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) {
return err return err
} }
func Hextob(str string) []byte {
slen := len(str)
bHex := make([]byte, len(str)/2)
ii := 0
for i := 0; i < len(str); i = i + 2 {
if slen != 1 {
ss := string(str[i]) + string(str[i+1])
bt, _ := strconv.ParseInt(ss, 16, 32)
bHex[ii] = byte(bt)
ii = ii + 1
slen = slen - 2
}
}
return bHex
}
func connHandler(c net.Conn, msg string) (result string) { func connHandler(c net.Conn, msg string) (result string) {
defer c.Close() defer c.Close()
//缓冲 //缓冲
buf := make([]byte, 1024) buf := make([]byte, 1024)
//写入数据 //写入数据
c.Write([]byte(msg)) c.Write(Hextob(msg))
//服务器端返回的数据写入buf //服务器端返回的数据写入buf
for { for {
n, _ := c.Read(buf) n, _ := c.Read(buf)