lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Lwip 1.3.0 Running out of TCP PCB's fast


From: B B
Subject: [lwip-users] Lwip 1.3.0 Running out of TCP PCB's fast
Date: Wed, 27 Aug 2008 13:48:29 +0200

Hi all,
 
I am running lwip + freertos on a LPC2468 and using the YAGARTO tool chain.
 
I have two task running, which uses lwip. One which is serving a webpage (listening pcb) and the other which
is connecting to a remote server once every minute (TCP connection).
 
in lwipopts.h i have the following define:
 

/**

* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.

* (requires the LWIP_TCP option)

*/

#define MEMP_NUM_TCP_PCB 10
 
 
Now when i connect to the devices webpage, the number of used tcp_pcb goes up.
And after 10 page hits, the stats say the following:
 
TCP_PCB avail: 10
TCP_PCB used: 10
TCP_PCB max: 10
TCP_PCB err: 5
TCP_PCB_LISTEN avail: 3
TCP_PCB_LISTEN used: 1
TCP_PCB_LISTEN max: 1
TCP_PCB_LISTEN err: 0

 
 
i've thought that "TCP_PCB used" should be 2, one for each connection. But that is not the case.
Is there anything i can do to avoid this situation ?
 
here is my code for my webserver task:
 
....
// Setup ethernet interface

HandleDHCP();

 

// Create a new tcp connection handle

pxHTTPListener = netconn_new( NETCONN_TCP );

netconn_bind(pxHTTPListener, NULL, webHTTP_PORT );

netconn_listen( pxHTTPListener );

/* Loop forever */

for( ;; )

{

   if (netif_is_up(&EMAC_if))

   {

      /* Wait for connection. */

      // Set receive timeout. This is a "hack" into LWIP and is not thread safe. But since

     // the connection isn't shared between tasks, this should be OK!

     // We set a receive timeout to prevent netconn_accept() from blocking

     // this task indefinitely. If the ethernet interface is brought down.

     pxHTTPListener->recv_timeout = 1000;

     pxNewConnection = netconn_accept(pxHTTPListener);

      if(pxNewConnection != NULL)

     {

       // Service connection.

       vProcessConnection( pxNewConnection );

         while( netconn_delete( pxNewConnection ) != ERR_OK )

       {

           vTaskDelay( webSHORT_DELAY );

       }

     }

   }

    else

   {

      // Setup ethernet interface

      HandleDHCP();

      vTaskDelay( webSHORT_DELAY );

   }

}
 
 
Should the above cause this behaviour ?
 
Beset regards,
Martin


Explore the seven wonders of the world Learn more!

reply via email to

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