Hi Christoph:

Indeed, I write the web server  with socket api in lwIP. It responses http 
request with a dynamic web page ( fetch interval 1 second).
After it run, I open 10 IE to access the web serve (I make sure 10 clients 
could access the web server at same time )r, and keep that in pressure testing…
 it had works in 3 days now , but I don’t think it is enough.


Vincent Cui
Sr.Firmware Engineer
Mobile: +8613482482211
Tel: +86 21 34612525x6104
Fax: +86 21 34619770
E-Mail: vincent....@enlogic.com<mailto:vincent....@enlogic.com>
Shanghai EnLogic Electric Technology Co., Ltd.
Address: 1104-1106, Building A, No.391, Guiping Road, Xuhui District, Shanghai, 
200233
http://www.enlogic.com

From: lwip-users-bounces+vincent.cui=enlogic....@nongnu.org 
[mailto:lwip-users-bounces+vincent.cui=enlogic....@nongnu.org] On Behalf Of 
Christoph Kronen
Sent: 2011年8月30日 15:31
To: Mailing list for lwIP users
Subject: Re: [lwip-users] FreeRTOS / lwip multiple connections

Hi Vincent,

I changed the receiving process to be nonblocking, it wasn't like this in the 
first place. The code below has the same entry point as your 
"vHandler_HTTP(__pstNewConn);", it gets called when the connection is already 
established.

My problem was the following: I needed to check for new data received via 
Ethernet as well as new data from a Sendqueue in the same task. So 
netconn_recv() could not be blocking. In another topic, Simon Goldschmitt 
suggested to use lwIP 1.3.1 and to set "LWIP_SO_RCVTIMEO" to make 
netconn_recv() nonblocking. Unfortunately this crashed my Sam7X all the time.

So what I do now, is to peek into the receive mailbox and only if there is data 
I start the netconn_recv() process. Probably horrible programming, but it works 
for now.

Richard suggested to use semaphores on TCP events, that sounds much cleaner and 
I will definitely try to do it that way. But then I would need a FreeRTOS 
function like "WaitForMultipleObjects", since the Task needs to wake up for 
either a TCP event semaphore OR a new element in my SendQueue.

The CommandInterpreter from Richards socket example (thanks !) works for my 
Sam7X and I am in the process of rewriting it to have the same functionality as 
the code below.

@Vincent: You said your webserver is able to have multiple connections, could 
you give me a tip on that ? Do you have a small code example for 
"multiconnection socket" part ?

Thank you very much,

Christoph

static void vProcessSpeedtest( struct netconn *pxNetCon )
{
struct netbuf *pxRxBuffer;
struct pbuf *dummybuffer;
unsigned char *pcRxString;
xTCP_TXBuff * TXPointer = 0;
unsigned short usLength;
    while (1)
    {
        // Peek into the Receive mailbox
        if ( pdTRUE == xQueuePeek((pxNetCon->recvmbox),&dummybuffer,0))
        {
            pxRxBuffer = netconn_recv( pxNetCon );
            if( pxRxBuffer != NULL )
            {
                do
                {
                    netbuf_data( pxRxBuffer, ( void * ) &pcRxString, &usLength 
);

                    //use the incoming data at this point

                }   while ( netbuf_next(pxRxBuffer) >=0 );
                netbuf_delete( pxRxBuffer );
            }
            else break;
        }
        // Check the Transmit Queue for Data and send it
        if ( xQueueReceive( xTXPointerQueue, &TXPointer, 0 ))
        {
            netconn_write(pxNetCon, TXPointer->data, TXPointer->length, 
NETCONN_NOFLAG);
            vFreeTCPBuffer(TXPointer);
        }
        vTaskDelay( 1 / portTICK_RATE_MS );
    }
    netconn_close( pxNetCon );
}




-------- Original-Nachricht --------
Datum: Tue, 30 Aug 2011 03:28:07 +0000
Von: vincent cui <vincent....@enlogic.com>
An: Mailing list for lwIP users <lwip-users@nongnu.org>
Betreff: Re: [lwip-users] FreeRTOS / lwip multiple connections
Hi Chistoph:












The "lwIP Embedded Webserver Demo" is what I took as a starting point. I 
removed the webserver functionality, now I have a task that





  *   checks for incoming data (nonblocking)



  *   checks a Queue for outgoing data (nonblocking)



  *   wait 1 ms (to prevent 100% cpu usage)



  *   repeat :-)






the LwIP webserver demo code is following, I don’t know how do  you infer it is 
noblocking for incoming data and outgoing ….




Where to wait 1 ms .








void  WebServer_Handler(void *pdata)




{




         struct netconn  *__pstConn, *__pstNewConn;









    __pstConn = netconn_new(NETCONN_TCP);




    netconn_bind(__pstConn, NULL,80);




    netconn_listen(__pstConn);








         for(;;)




         {




                   __pstNewConn = netconn_accept(__pstConn);









                   if(__pstNewConn != NULL)




                   {




                            vHandler_HTTP(__pstNewConn);




                            while(netconn_delete(__pstNewConn) != ERR_OK)




                            {




                                     vTaskDelay(10);




                            }




                   }




    }




}
















Vincent Cui
Sr.Firmware Engineer
Mobile: +8613482482211
Tel: +86 21 34612525x6104
Fax: +86 21 34619770
E-Mail: 
vincent....@enlogic.com<https://service.gmx.net/de/cgi/g.fcgi/mail/new?CUSTOMERNO=4533556&t=de1430282668.1314686049.72c8b5f4&to=vincent.cui%40enlogic.com>
Shanghai EnLogic Electric Technology Co., Ltd.
Address: 1104-1106, Building A, No.391, Guiping Road, Xuhui District, Shanghai, 
200233
http://www.enlogic.com









From: 
lwip-users-bounces+vincent.cui=enlogic....@nongnu.org<https://service.gmx.net/de/cgi/g.fcgi/mail/new?CUSTOMERNO=4533556&t=de1430282668.1314686049.72c8b5f4&to=lwip-users-bounces%26%2343%3Bvincent.cui%3Denlogic.com%40nongnu.org>
 
[mailto:lwip-users-bounces+vincent.cui=enlogic....@nongnu.org]<https://service.gmx.net/de/cgi/g.fcgi/mail/new?CUSTOMERNO=4533556&t=de1430282668.1314686049.72c8b5f4&to=lwip-users-bounces%26%2343%3Bvincent.cui%3Denlogic.com%40nongnu.org>
 On Behalf Of Christoph Kronen
Sent: 2011年8月29日 0:48
To: 
lwip-users@nongnu.org<https://service.gmx.net/de/cgi/g.fcgi/mail/new?CUSTOMERNO=4533556&t=de1430282668.1314686049.72c8b5f4&to=lwip-users%40nongnu.org>
Subject: [lwip-users] FreeRTOS / lwip multiple connections








Hi all,

I am using FreeRTOS 7.0.1 on a Sam7X512 and upgraded the contributed port lwIP 
1.3.0 to 1.3.2.

The "lwIP Embedded Webserver Demo" is what I took as a starting point. I 
removed the webserver functionality, now I have a task that





  *   checks for incoming data (nonblocking)



  *   checks a Queue for outgoing data (nonblocking)



  *   wait 1 ms (to prevent 100% cpu usage)



  *   repeat :-)



This works pretty well, I get around 1400 kbyte/s RX and TX.
Now to my question: Is it possible/difficult/easy to transform this 
functionality to accept multiple connections on the same port ? At the moment I 
am using the netconn API, so I guess I have to switch to the Socket API ?

I read through Richards thread on his "FreeRTOS/lwip Win32 simulator" project 
and it sounds as if it is quite difficult to have multiple connections in a 
multithreaded environment. Unfortunately I could not find other helpful topics 
or contributed examples.

I am rather new to FreeRTOS and lwIP, so please excuse me if I am missing 
something obvious :-)

Please give me some comments / suggestions / tips / pushes into the right 
direction.

Thank you very much !

Christoph




_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to