lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Listen on more then one port with lwIP


From: YAP
Subject: [lwip-users] Listen on more then one port with lwIP
Date: Thu, 1 Jan 2009 23:00:54 +0100

I am new to lwIP and use it with FreeRTOS on a PIC32 so be patient
with  me if this is just a  silly question.

I want to have a web server plus a custom interface on the firmware I
work on at the moment. So I try to solve this starting a new thread
where I initialised lwip and then start two listner threads for the
two ports.

This does not work however even if they each work perfect on there own.

How should this be coded correctly?  Any hints appreciated.

My listner thread look like this

///////////////////////////////////////////////////////////////////////////////
// taskVSCPListner
//

void taskVSCPListner( void *pvParameters )
{
    struct netconn *pxVSCPListener;     // Listens for VSCP connections
    struct netconn *pxNewConnection;

    // Create a new tcp connection handle for VSCP
        pxVSCPListener = netconn_new( NETCONN_TCP );
        netconn_bind( pxVSCPListener, NULL, VSCP_LEVEL2_TCP_PORT );
        netconn_listen( pxVSCPListener );

        // Loop forever
        for( ;; ) {
        
                // Wait for connection.
                pxNewConnection = netconn_accept( pxVSCPListener );

                if ( pxNewConnection != NULL ) {
                
                        // Service connection.
                        vProcessVSCPConnection( pxNewConnection );
                
                while( netconn_delete( pxNewConnection ) != ERR_OK ) {
                                vTaskDelay( webSHORT_DELAY );
                        }
                
                }
                
        }
}


///////////////////////////////////////////////////////////////////////////////
// taskHTTPListner
//

void taskHTTPListner( void *pvParameters )
{
    struct netconn *pxHTTPListener;     // Listens for HTTP connections
    struct netconn *pxNewConnection;

    // Create a new tcp connection handle for HTTP
        pxHTTPListener = netconn_new( NETCONN_TCP );
        netconn_bind( pxHTTPListener, NULL, webHTTP_PORT );
        netconn_listen( pxHTTPListener );
        
        // Create a new tcp connection handle for VSCP
        //pxVSCPListener = netconn_new( NETCONN_TCP );
        //netconn_bind( pxHTTPListener, NULL, VSCP_LEVEL2_TCP_PORT );
        //netconn_listen( pxVSCPListener );

        // Loop forever
        for( ;; ) {
        
                // Wait for connection.
                pxNewConnection = netconn_accept( pxHTTPListener );

                if ( pxNewConnection != NULL ) {
                
                        // Service connection.
                        vProcessConnection( pxNewConnection );
                
                while( netconn_delete( pxNewConnection ) != ERR_OK ) {
                                vTaskDelay( webSHORT_DELAY );
                        }
                
                }
                
        }
}

Cheers
/Ake


-- 
 ---
Ake Hedman
D of Scandinavia, http://www.dofscandinavia.com




reply via email to

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