lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Opening a TCP session, using LwIp Rev 1.4.1


From: Avi
Subject: [lwip-users] Opening a TCP session, using LwIp Rev 1.4.1
Date: Thu, 21 Aug 2014 08:16:52 -0700 (PDT)

Hi

I am using LwIp Rev 1.4.1, on an an embeded system, and trying to open a TCP
session against Jpref TCP test tool, running on PC, and the session is not
opened.

*The source code on my system, for opening the TCP session:*

#define TCP_TEST_PORT           ( 5001 )

struct netconn *TcpTestListener, *pxNewConnection;
uint status = 0;
struct netbuf *pxRxBuffer;
char *pcRxString;
unsigned short usLength;

/* Create a new tcp connection handle */
TcpTestListener = netconn_new( NETCONN_TCP );
ZR_ASSERT(TcpTestListener != NULL);
status = netconn_bind(TcpTestListener, IP_ADDR_ANY, TCP_TEST_PORT );
ZR_ASSERT(status == TX_SUCCESS);
status = netconn_listen( TcpTestListener );
ZR_ASSERT(status == TX_SUCCESS);

/* Loop forever */
for( ;; )
{
        /* Wait for connection. */
        status = netconn_accept(TcpTestListener, &pxNewConnection);
        ZR_ASSERT(status == TX_SUCCESS);

        if((status == TX_SUCCESS) && (pxNewConnection != NULL))
        {
                /* Service connection. */

                /* We expect to immediately get data. */
                status = netconn_recv( pxNewConnection, &pxRxBuffer );
                ZR_ASSERT(status == TX_SUCCESS);

                if( pxRxBuffer != NULL )
                {
                        /* Where is the data? */
                        status = netbuf_data( pxRxBuffer, (void **)&pcRxString, 
&usLength );
                        ZR_ASSERT(status == TX_SUCCESS);

                        /* Write back the data */
                        status = netconn_write(pxNewConnection, pcRxString, 
(u16_t)usLength,
NETCONN_COPY );
                        ZR_ASSERT(status == TX_SUCCESS);

                        netbuf_delete( pxRxBuffer );
                }
                status = netconn_close( pxNewConnection );
                ZR_ASSERT(status == TX_SUCCESS);

                while( netconn_delete( pxNewConnection ) != ERR_OK )
                {
                        tx_thread_sleep(20000);
                }
        }
}

Do you about a problem when working against the Jpref tool, or you see a
problem in my code ?

Thanks
Avi





--
View this message in context: 
http://lwip.100.n7.nabble.com/Opening-a-TCP-session-using-LwIp-Rev-1-4-1-tp23056.html
Sent from the lwip-users mailing list archive at Nabble.com.



reply via email to

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