Receive muliple packages

Hi, I’m using a SAM4E EK with the GMAC example from the atmel asf. I’m running into some problems with receiving multiple packages. I can receive a request and then send the website in multiple packages but can’t receive multiple packages. I hope that you guys can help me because I can’t think of anything else. ~~~ for( ;; ) { #if ( (LWIPVERSION) == ((1U << 24) | (3U << 16) | (2U << 8) | (LWIPVERSIONRC)) ) /* Wait for a first connection. */ pxNewConnection = netconnaccept(pxHTTPListener); #else while(netconnaccept(pxHTTPListener, &pxNewConnection) != ERROK) { vTaskDelay( webSHORTDELAY ); } #endif vParTestSetLED(webCONNLED, pdTRUE);
    if(pxNewConnection != NULL)
    {
        prvweb_ParseHTMLRequest(pxNewConnection);
        }/* end if new connection */

        vParTestSetLED(webCONN_LED, pdFALSE);

        } /* end infinite loop */
    }


    /*! brief parse the incoming request
    *         parse the HTML request and send file
    *
    *  param pxNetCon   Input. The netconn to use to send and receive data.
    *
    */
    static void prvweb_ParseHTMLRequest( struct netconn *pxNetCon )
    {
        struct netbuf *pxRxBuffer;
        portCHAR *pcRxString;
        unsigned portSHORT usLength;


        #if ( (LWIP_VERSION) == ((1U << 24) | (3U << 16) | (2U << 8) | (LWIP_VERSION_RC)) )
        /* We expect to immediately get data. */
        pxRxBuffer = netconn_recv( pxNetCon );
        #else
        while(netconn_recv( pxNetCon, &pxRxBuffer) != ERR_OK)
        {
            vTaskDelay( webSHORT_DELAY );
        }
        #endif
        if( pxRxBuffer != NULL )
        {
            /* Where is the data? */
            netbuf_data( pxRxBuffer, ( void * ) &pcRxString, &usLength );

            /* Is this a GET?  We don't handle anything else. */
            if(( NULL != pcRxString)&& ( !strncmp( pcRxString, "GET", 3 ) ))
            {
                /* Write out the HTTP OK header. */
                netconn_write( pxNetCon, webHTTP_OK, (u16_t) strlen( webHTTP_OK ), NETCONN_COPY );

                strcpy( cDynamicPage, Webpage1 );
                netconn_write( pxNetCon, cDynamicPage, (u16_t) strlen( cDynamicPage ), NETCONN_COPY );

                strcpy( cDynamicPage, Webpage2 );
                netconn_write( pxNetCon, cDynamicPage, (u16_t) strlen( cDynamicPage ), NETCONN_COPY );
            }
            if(( NULL != pcRxString) && ( !strncmp( pcRxString, "POST", 4 )))
            {
                printf("nr%s",pcRxString);
                netbuf_delete( pxRxBuffer);
                while(netconn_recv( pxNetCon, &pxRxBuffer) != ERR_OK)
                {
                    vTaskDelay( webSHORT_DELAY );
                }
                if( pxRxBuffer != NULL )
                {
                    /* Where is the data? */
                    netbuf_data( pxRxBuffer, ( void * ) &pcRxString, &usLength );
                    printf("nr%s",pcRxString);
                }



            }
            netbuf_delete( pxRxBuffer);
        }

        netconn_close( pxNetCon );
        netconn_delete( pxNetCon );

    }
~~~

Receive muliple packages

I don’t think this is code we provided, or using our TCP stack. I would recommend requesting support from whoever wrote the code.

Receive muliple packages

Hi Bob,
I’m using a SAM4E EK with the GMAC example from the atmel asf. I’m running into some problems with receiving multiple packages. I can receive a request and then send the website in multiple packages but can’t receive multiple packages.
I’m reading your function prvweb_ParseHTMLRequest() : ~~~ netconnclose( pxNetCon ); netconndelete( pxNetCon ); ~~~ Why does this function close and delete the connection? More requests might follow… Instead of lwIP, you may also check out FreeRTOS+TCP If you want the latest sources, you better download the official FreeRTOS release or have a look at https://aws.amazon.com/freertos

Receive muliple packages

The function that you are showing looks like sample code, a “hello world” for HTTP. FreeRTOS+TCP contains a more complete example of a HTTP server, that keeps connections open. This server is still simple though, and it only implements the “GET” command. It uses FreeRTOS+FAT to read files from either a RAM-disk or an SD-card. The client browser will send a request as e.g. : ~~~ GET /index.html HTTP/1.1 Host: my_host Connection: keep-alive ~~~ The server will answer it: ~~~ HTTP/1.1 200 OK Content-Type: text/html Connection: keep-alive Content-Length: 6081
"Contents ... " ( 6081 bytes )
~~~ It is possible that the browser sends a series of GET requests, without first waiting for the returning data. Of course this technique is much more efficient than doing one request per TCP connection.