Hello, I have got issue with TCP server disconnection.
Version: lwip-2.1.2 Code: Pattern I am working with: /* TCP connection setup */ struct netconn *conn, *newconn; err_t err = ERR_OK; conn = netconn_new( NETCONN_TCP ); err = netconn_bind( conn, &ipAddr, tcpPort ); netconn_listen( conn ); for( ;; ) { /* Grab new connection */ err = netconn_accept(conn, &newconn); /* Process the new connection */ if (err == ERR_OK) { while ( err == ERR_OK ) { struct netbuf *rxBuf = NULL; err = netconn_recv( newconn, &rxBuf ); /* Continuously get data requests from TCP Client and send response */ do { /* Get data from netbuf */ netbuf_data(rxBuf, &requestReceived, &reqLength); /* Prepare transmit buffer */ struct netbuf* txBuf; txBuf = netbuf_new(); (void)netbuf_alloc( txBuf, MB_MAX_MESSAGE_LENGTH ); /* Analyze request and prepare response * */ err = netconn_write( newconn, txBuf->p->payload, rspLength, NETCONN_COPY ); /* Delete transmit buffer */ netbuf_delete( txBuf ); } while ( ( err == ERR_OK ) && (netbuf_next( rxBuf ) >= 0 ) ); /* Delete receive buffer */ netbuf_delete( rxBuf ); } } if ( newconn != NULL ) { netconn_close( newconn ); netconn_delete( newconn ); } vTaskDelay( pdMS_TO_TICKS( TRY_RECONNECT_TIME ) ); } Server app (lwip) is a part of embedded system. TCP Client Test application is running on my PC. There are 2 ways of disconnection which I have tested: CASE 1. Turn off Client application (cable between my PC and embedded system remain connected). Registered errors: ERR_CONN/** Not connected. */ or ERR_RST/** Connection reset. */ or ERR_CLSD/** Connection closed. */ Resources were properly freed. In lwip_stats.memp[0] (MEMP_TCP_PCB)) was decreased by 1. I can make new connection by run Client application on PC and connection is being established. Everything works fine. CASE 2. Disconnect eth cable by removing RJ45 connector. Registered errors: ERR_RTE/** Routing problem. */ Resources WERE NOT properly freed. In lwip_stats.memp[0] (MEMP_TCP_PCB)) is on the same level as before cable disconnection. I can make new connection but number of used resources is increasing every time new connection is being established. How can I handle cable disconnection to achieve resource release as in case 1? Have you had similar issues? Best Regards, Michał Timm WB Electronics S.A. 05-850 Ozarow Mazowiecki, ul. Poznanska 129/133 NIP: 526-216-83-87 REGON: 0128903491 KRS: 0000369722 W.K.Z.: 516 616,35 PLN Sad Rejonowy dla m. st. WARSZAWY w Warszawie XIV Wydzial Gospodarczy Krajowego Rejestru Sadowego Powyższa wiadomość stanowi własność WB Electronics, jest przeznaczona wyłącznie dla jej adresata/adresatów i może zawierać informacje prawnie chronione. Jeżeli otrzymali Państwo e-mail omyłkowo, proszę o poinformowanie nadawcy oraz niezwłoczne usunięcie wiadomości wraz z jej załącznikami. Ujawnianie, kopiowanie lub rozpowszechnianie treści korespondencji lub załączników bez zgody nadawcy jest zabronione. The message is intended only for its addressee(s), is owned by WB Electronics and may contain information protected by law. If you are not the addressee and have received this e-mail, please notify the sender and delete this message and all its attachments from your computer. Any copying or dissemination of the message or its attachments must first be approved by the sender.
_______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users