This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 2014e3a2e361d71877a4ef37a7a0e10b1bb2b87d
Author: Marco Casaroli <[email protected]>
AuthorDate: Mon Nov 2 11:19:16 2026 +0100

    examples/tcp_ipc_server: Do not die of SIGPIPE when a client closes.
    
    The client thread sends the response with send().  When the client
    closed the connection, the send fails with EPIPE.  A send to a stream
    socket whose peer is gone also raises SIGPIPE, and with
    CONFIG_SIG_SIGPIPE_ACTION the default action ends the server for all
    clients.
    
    Send with MSG_NOSIGNAL.  The thread reports the error, and the next
    read() reports the closed connection and ends the thread, as before.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 examples/tcp_ipc_server/tcp_ipc_server_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/examples/tcp_ipc_server/tcp_ipc_server_main.c 
b/examples/tcp_ipc_server/tcp_ipc_server_main.c
index 5953f9b48..9464edf09 100644
--- a/examples/tcp_ipc_server/tcp_ipc_server_main.c
+++ b/examples/tcp_ipc_server/tcp_ipc_server_main.c
@@ -90,7 +90,6 @@ static void *thread_socket_client(void *arg);
 #define SOCKET_PORT                         5000
 #define TX_BUFFER_SIZE                      200
 #define RX_BUFFER_SIZE                      150
-#define TCP_NO_FLAGS_WHEN_SENDING_DATA      0
 #define IP_SERVER                           "127.0.0.1"
 #define MAX_PENDING_SOCKET_CONNECTIONS      20
 #define TIME_TO_CHECK_FOR_NEW_CLIENTS       500000
@@ -144,7 +143,7 @@ static void *thread_socket_client(void *arg)
               ret_send = send(socket_client_fd,
                               tx_buffer,
                               sizeof(protocolo_ipc),
-                              TCP_NO_FLAGS_WHEN_SENDING_DATA);
+                              MSG_NOSIGNAL);
 
               if (ret_send > 0)
                 {

Reply via email to