lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Disconnect client from LWIP server on various occassions


From: Matthias Paul
Subject: [lwip-users] Disconnect client from LWIP server on various occassions
Date: Wed, 16 Mar 2022 14:43:35 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0

Hello LWIP users,

currently using raw API for LWIP server implementation.

1. When the network cable is disconnected, I'd like to disconnect all clients connected to my LWIP server, otherwise those connections are kept connected from the server side. Installed the callback for netif changes (see netif_set_status_callback()). The callback _is_ called. Now it's not clear to me how to close all connections assigned to that network interface. Should I iterate over linked list tcp_active_pcbs (declared in tcp_priv.h) and close them all? Or is there a better way?

2. Based on tcpecho_raw example in contribution package 2.1.0 (contrib2.1.0/apps/tcpecho_raw/): If the received pbuf pointer in tcpecho_raw_recv() is NULL, the connection has been closed by the remote. Now the code waits to send out all unsent data before actually closing the connection:

 (p == NULL) {
    /* remote host closed connection */
    es->state = ES_CLOSING;
    if(es->p == NULL) {
      /* we're done sending, close it */
      tcpecho_raw_close(tpcb, es);
    } else {
      /* we're not done yet */
      tcpecho_raw_send(tpcb, es);
    }
    ret_err = ERR_OK;
  }

If the LWIP server sends a long data stream (some megabytes of data) while receiving the remote disconnect, I'll run into problems because the server stalls: tcp_sent() is never called afterwards, so the server cannot push further data to the client . Can anyone explain why the connection isn't closed instantly by call to tcpecho_raw_close()?


Thank you for reading,

Paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]