lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] POST data using several packets


From: Jesper Vestergaard
Subject: Re: [lwip-users] POST data using several packets
Date: Thu, 25 Jun 2009 16:48:48 +0200
User-agent: Thunderbird 2.0.0.21 (X11/20090409)

Kieran Mansley wrote:
On Wed, 2009-06-24 at 14:03 +0200, Jesper Vestergaard wrote:
what is the prober way of assembling the data from a arbitrary number of packets?

Call netconn_recv() repeatedly and concatenate the data you get until
you have as much as you want.

Kieran
I have tried calling netconn_recv() repeatedly but a problem has occured. I get the data fine but when i will respond to the request with netconn_write(pxNetCon, cDynamicPage, (u16_t)strlen( cDynamicPage ), NETCONN_COPY ); no data is being sent. The code for retrieving the data is here:

/pxNetCon->recv_timeout=20;
/* Data is ready */ pxRxBuffer = netconn_recv( pxNetCon );
       pcRxString = pvPortMalloc( mem_size );
       do
       {
           /* Where is the data? */
netbuf_data( pxRxBuffer, ( void * ) &(pcRxString2), &usLength ); /* Allocate memory for the data */
           mem_size = mem_size + usLength;
           pcRxString = pvPortRealloc( pcRxString, (mem_size) );
/* In the first iteration we can copy the data as it is */
           if (mem_size == usLength)
           {
               memcpy(pcRxString, pcRxString2, usLength);
           }
           else
           {
               pcRxString3 = pvPortMalloc( usLength + 1 );
               memcpy(pcRxString3, pcRxString2, usLength);
/* We use string functions on a char array so add a null terminator */
               pcRxString3[usLength] = '\0';
               strcat( pcRxString, pcRxString3 );
vPortFree( pcRxString3 ); } netbuf_free( pxRxBuffer );
           pxRxBuffer = netconn_recv( pxNetCon );
           //pxRxBuffer = NULL;
       }
       /* if theres is no more packets in the buffer proceed */
       while (pxRxBuffer != NULL);/


If I comment the pxRxBuffer = netconn_recv( pxNetCon ); line and uncomment pxRxBuffer = NULL; The data is sent like it should. What is causing that and how do i fix it so i can recive multiple packets but still respond to the request?/
/




reply via email to

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