lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] telnet eats my memory


From: Adib Taraben
Subject: [lwip-users] telnet eats my memory
Date: Sun, 22 Mar 2009 13:18:20 +0100
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

Hello all,

I am trying to establish TCP server connection ad to push data from the server. I use the telnet example that comes with my board infineon XC167. The telnet.c is attached. Using #define LWIP_STATS_DISPLAY 1 and #define MEMP_STATS 1 I get some memory information: MEM PBUF_POOL avail: 32 used: 3 max: 4 err: 0
the used part never goes down to zero. I s this expected behaviour?
Do I need to free the memory myself after sending? But how?
Is there any other example? The most examples drop the connection after response (http_server) but I need to hold the connection.

Thx in advance,

Adib.
---
/***************************************************************************
 **                                                                       **
 **    Simple HTTP server which will dump a HTML page at each request     **
 **                                                                       **
 **    It is based on lwIP (CVS version 06.03.2003) by Adam Dunkels of    **
 **    Swedish Institute of Computer Science. See www.sics.se/~adam/lwip/ **
 **                                                                       **
 **    Ported 03/2003 by Christian Scheurer (www.ChristianScheurer.ch)    **
 **                                                                       **
 *************************************************************************** */


#include "lwip/tcp.h"
//#include "GPT1.h"

err_t telnet_accept(void *arg, struct tcp_pcb *pcb1,err_t err);


/* *** GLOBAL DATA AND DEFINITIONS ***************************************** */
                                
void telnet_init(void)
{

   struct tcp_pcb *pcb;
   pcb = tcp_new();
   tcp_bind(pcb, IP_ADDR_ANY, 23);
   pcb = tcp_listen(pcb);

}

/*****************************************************************************
 * lwip_tcp_event()                                                          *
 * This function is called to handle lwip events                             *
 *****************************************************************************/
err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb, enum lwip_event ev, struct 
pbuf *p, u16_t size, err_t err)
{
  int retvalue = ERR_OK;
  char * Welcome = "Hello World !\n\rYou can switch on and off the blinking 
LED\n\rPress 0 to stop the blinking and 1 to start it\n\rPress q to 
quit\n\r\n\r";
        char * OFF = "Blinking LED Switched OFF\n\r";
        char * ON = "Blinking LED Switched ON\n\r";

        printf("-t-");
  switch(ev){
    case LWIP_EVENT_ACCEPT:
                printf("ACCEPT ");
                        tcp_write(pcb, (unsigned char *)Welcome, 
strlen(Welcome), 1);
     break;
    case LWIP_EVENT_SENT:
                printf("SENT ");
      break;
    case LWIP_EVENT_RECV:
                printf("RECV ");
                                if (p!=NULL) {
                                switch (*(unsigned char *)p->payload) {
                                        case '0':
//                                              GPT1_vStopTmr_GPT1_TIMER_2();
                                                if(tcp_write(pcb, (unsigned 
char *)OFF, strlen(OFF), 1) != ERR_OK)
                                                        printf("uups");
                                                break;
                                        case '1':
//                                              GPT1_vStartTmr_GPT1_TIMER_2();
                                                if(tcp_write(pcb, (unsigned 
char *)ON, strlen(ON), 1) != ERR_OK)
                                                        printf("uups");
                                                break;
                                        case 'q':
                                                tcp_close(pcb);
                                                break;
                                        default:
                                break;          
                                        }
                        }
      break; 
    case LWIP_EVENT_CONNECTED:
                printf("CONNECTED ");
      break;
    case LWIP_EVENT_POLL:
                printf("POLL ");
      break;
    case LWIP_EVENT_ERR :
                printf("ERR ");
      break;
    default:
                printf("default ");
      break;
  }  
  return retvalue;
}

reply via email to

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