From 7804d97a4563f999c16beee324fce9eb7f0a21f4 Mon Sep 17 00:00:00 2001 From: wangfq Date: Wed, 1 Jul 2026 09:52:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20listen=20socket=20CONNECT=20=E4=B8=8D?= =?UTF-8?q?=E5=BA=94=E8=A7=A6=E5=8F=91=20accepted=20=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - WCHNET_HandleSockInt 第二路由条件增加 socketid!=g_json_socket_listen - tcp_json_handle_sock_int 'Newly accepted' 检查增加 socketid!=g_json_socket_listen - 防止 listen socket 的 CONNECT 事件误触发 WCHNET_ModifyRecvBuf 和 g_json_socket_client 覆写 根因:TCP_LISTEN socket 和 accepted client 是不同 socket ID(1 vs 3), listen socket 的 CONNECT 不应穿透到 'newly accepted' 分支去配置 recv buffer, 否则会干扰 WCHNET 对 accepted socket 的数据路由 --- vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/net_srv.c | 6 ++++-- vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/net_srv.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/net_srv.c index dc6c42d..a938752 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/net_srv.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/net_srv.c @@ -481,13 +481,15 @@ void WCHNET_HandleSockInt(uint8_t socketid, uint8_t intstat) { uint8_t i; - // Route JSON protocol socket events + // Route JSON protocol socket events (listen socket, client socket) if (socketid == g_json_socket_listen || socketid == g_json_socket_client) { tcp_json_handle_sock_int(socketid, intstat); return; } // Also catch newly accepted TCP connections that might be JSON clients - if ((intstat & SINT_STAT_CONNECT) && socketid != SocketId_TCP && socketid != SocketId_UDP) { + // Exclude: listen socket, SSC TCP, UDP + if ((intstat & SINT_STAT_CONNECT) && socketid != g_json_socket_listen + && socketid != SocketId_TCP && socketid != SocketId_UDP) { tcp_json_handle_sock_int(socketid, intstat); return; } diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c index 5bd0232..b60d248 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c @@ -662,8 +662,9 @@ void tcp_json_handle_sock_int(uint8_t socketid, uint8_t intstat) { } } - // === Newly accepted client (CONNECT on unknown socket) === + // === Newly accepted client (CONNECT on unknown socket, but NOT the listen socket) === if ((intstat & SINT_STAT_CONNECT) && socketid != g_json_socket_client + && socketid != g_json_socket_listen && socketid != SocketId_TCP && socketid != SocketId_UDP) { g_json_socket_client = socketid; g_json_auth_state = JSON_STATE_WAIT_AUTH;