修改长连接中断的问题

This commit is contained in:
zyj
2025-11-12 18:39:50 +08:00
parent 7469cf22ea
commit 6bf2bb4c9c

View File

@@ -39,6 +39,7 @@ func readN(conn net.Conn, n int, timeout time.Duration) ([]byte, error) {
} }
total += nr total += nr
} }
conn.SetReadDeadline(time.Time{})
return buf, nil return buf, nil
} }
@@ -81,6 +82,7 @@ func TransportTo(conn net.Conn, serial string) error {
if status != "OKAY" { if status != "OKAY" {
return fmt.Errorf("unexpected transport status: %s", status) return fmt.Errorf("unexpected transport status: %s", status)
} }
conn.SetWriteDeadline(time.Time{})
return nil return nil
} }
@@ -192,14 +194,14 @@ func LaunchUiautomator(addr, serial string) {
return return
} }
// transport // transport
adbSend(conn, "host:transport:"+serial) // adbSend(conn, "host:transport:"+serial)
resp, _ := adbReadResponse(conn) // resp, _ := adbReadResponse(conn)
fmt.Println("transport resp:", resp) // fmt.Println("transport resp:", resp)
TransportTo(conn, serial)
// shell // shell
cmd := "shell:CLASSPATH=/data/local/tmp/u2.jar app_process / com.wetest.uia2.Main" cmd := "shell:CLASSPATH=/data/local/tmp/u2.jar app_process / com.wetest.uia2.Main"
adbSend(conn, cmd) adbSend(conn, cmd)
resp, _ = adbReadResponse(conn) resp, _ := adbReadResponse(conn)
fmt.Println("shell resp:", resp) fmt.Println("shell resp:", resp)
// 输出流 // 输出流