[Top][All Lists]

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

Re: [lwip-users] Using both sequential and raw APIs

From: address@hidden
Subject: Re: [lwip-users] Using both sequential and raw APIs
Date: Wed, 05 Nov 2008 17:34:48 +0100
User-agent: Thunderbird (Macintosh/20080914)

Your code will most certainly NOT work and mixing the APIs in this way is absolutely not supported. If you tried long enough (and maybe changed some lwIP code), you might get it working, but I don't see the point in that. Why do you want to mix the APIs anyway?

Oh, and does the "basic web server supplied with FreeRTOS" also mix the APIs? If so, it's a bad example of using lwIP...


CK Chan wrote:
i'm building a TCP client with lwIP 1.1.0 on top of FreeRTOS.
i tried to use both APIs but have problem receiving TCP packet. if i use netconn_recv() APIs, i can receive the packet. i'm trying to use tcp_recv() instead

most of the codes is from basic web server supplied with FreeRTOS.

will this work ?

static err_t
recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)

   // Inform TCP that we have taken the data
   tcp_recved(pcb, p->tot_len);

   return  ERR_OK;

void vBasicTCPClient( void *pvParameters )
struct netconn *pxTCPListener;// *pxTCPNewConnection;
struct ip_addr xIpAddr, xNetMast, xGateway, xIPHost, addr;
extern err_t ethernetif_init( struct netif *netif );
static struct netif EMAC_if;
err_t err;

   /* Parameters are not used - suppress compiler error. */
   ( void ) pvParameters;

   /* Create and configure the EMAC interface. */
IP4_ADDR(&xNetMast,emacNET_MASK0,emacNET_MASK1,emacNET_MASK2,emacNET_MASK3); IP4_ADDR(&xGateway,emacGATEWAY_ADDR0,emacGATEWAY_ADDR1,emacGATEWAY_ADDR2,emacGATEWAY_ADDR3); netif_add(&EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input);

   /* make it the default interface */

   /* bring it up */
     /* Create a new tcp connection handle */
       pxTCPListener = netconn_new( NETCONN_TCP );

       tcp_arg(pxTCPListener->pcb.tcp, NULL);
       tcp_recv(pxTCPListener->pcb.tcp, recv_tcp);  // set a callback

       IP4_ADDR(&xIPHost,192,168,1,101);      // IP of TCP server
       netconn_bind(pxTCPListener, NULL, tcpSERVER_PORT );
       err = netconn_connect(pxTCPListener, &xIPHost, tcpSERVER_PORT);
       if (err == ERR_OK)
         for( ;; )

thanks for your time !

lwip-users mailing list

reply via email to

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