This commit is contained in:
邹宗楠
2023-06-06 09:04:21 +08:00
parent a067a9ad92
commit 08f8c08c4d

View File

@@ -82,7 +82,7 @@ func ConReadAll(c net.Conn) ([]byte, int, error) {
return data, len(data), err
}
func ConnRead(c net.Conn) ([]byte, int, error) {
buffer := make([]byte, 1024)
buffer := make([]byte, 1024*2)
n, err := c.Read(buffer)
return buffer, n, err
}
@@ -99,17 +99,7 @@ func handleConn(c net.Conn, t *TcpClient) error {
defer c.Close()
for {
var printNo string //打印机编号
// 第一种
//buffer, n, err := ConReadAll(c)
//globals.SugarLogger.Debugf("ConReadAll : %s,%d,%v", string(buffer), n, err)
// 第二种
//buffer, n, err := ConnReadFull(c)
//globals.SugarLogger.Debugf("ConnReadFull : %s,%d,%v", string(buffer), n, err)
// 第三种(正常)
buffer, n, err := ConnRead(c)
globals.SugarLogger.Debugf("ConnRead : %s,%d,%v", string(buffer), n, err)
if err != nil {
if err == io.EOF {
fmt.Println("connection close")