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


_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to