[Top][All Lists]

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

[lwip-users] Using both sequential and raw APIs

From: CK Chan
Subject: [lwip-users] Using both sequential and raw APIs
Date: Wed, 05 Nov 2008 17:14:39 +0800
User-agent: Thunderbird (Windows/20080914)

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 !

reply via email to

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