This commit is contained in:
邹宗楠
2026-05-12 16:30:39 +08:00
parent 35c8468789
commit 3cb53546f8
2 changed files with 74 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-print/globals"
"io"
"net"
"strings"
@@ -59,8 +60,17 @@ func handleConn(c net.Conn) error {
}
for {
buffer, n, err := ConnRead(c)
remoteAddr := c.RemoteAddr().(*net.TCPAddr)
remoteIP := remoteAddr.IP.String() // 打印机IP
remotePort := remoteAddr.Port // 打印机端口
globals.SugarLogger.Debugf("remoteIP1: %s", remoteIP)
globals.SugarLogger.Debugf("remotePort1: %d", remotePort)
printRemoteAddr := c.RemoteAddr().String()
printRemoteAddr = strings.Split(printRemoteAddr, ":")[0]
globals.SugarLogger.Debugf("printRemoteAddr2: %s", printRemoteAddr)
if err != nil {
if err == io.EOF {
fmt.Println("connection close")