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: Fri, 26 Jun 2009 11:04:10 +0200
User-agent: Thunderbird 2.0.0.22 (X11/20090608)

Jesper Vestergaard wrote:
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 add pxNetCon->err = ERR_OK; after the do while everything works. It seems that ERR_TIMEOUT is treated as a fatal error and lwip wont send anything trough the connection if a timeout occurs.


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?/
/


_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users







reply via email to

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