lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Multiple connections at the same time (netconns)


From: ncoage
Subject: [lwip-users] Multiple connections at the same time (netconns)
Date: Thu, 19 Feb 2009 09:00:57 +0100

Hi,

I'm using lwip with FreeRTOS. How can I write a server that accept connections, 
but dont disconnect them after transfering data. In other words I must to have 
a multiple opened connections waiting for incoming data. Is that true, that I 
must to create task for particular connection?

This is my idea (it's working, but uses too much RAM):

// - Server task -----------------------------------
void server(void *parameters)
{
    struct netconn *conn = NULL;
    struct netconn *newconn = NULL;
    conn = netconn_new(NETCONN_TCP);
    netconn_bind(conn, NULL, 502);
    netconn_listen(conn);
    for (;;)
    {
        newconn = netconn_accept(conn);
        // creating new task
        xTaskCreate( serviceTask, "svc", STACK, (void*)newconn, PRIORITY, NULL) 
)
    }
}

// - Connection service task -----------------------------------
void modbusServiceConn(void *conn)
{
    struct netbuf *inbuf = NULL;
    uint8_t *data = NULL;
    int len;

    while (inbuf = netconn_recv(conn))
    {
        netbuf_data(inbuf, (void *)&data, (void *)&len);
        // data processing
        netbuf_delete(inbuf);
        inbuf = NULL;
    }
    netconn_delete(conn);
    conn = NULL;
    vTaskDelete( NULL );
}

Regards, 
Gregory




reply via email to

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