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


_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to