lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] [lwip] Is this a correct tcp echo client ????


From: serpeal
Subject: [lwip-users] [lwip] Is this a correct tcp echo client ????
Date: Thu, 09 Jan 2003 00:45:16 -0000

Hello everybody!!

I'm testin lwip on linux with the project simhost and everythings goes fine with
tapif using telnet, www browsers etc, but I've tried to write a tcp echo client
program wich tries to simulate a telnet call to tcp port 7.

This is the program: 

static void tcpclient(void *arg){
  static struct netconn *conn;
  struct ip_addr ipaddr;
  char data[5];
  sys_sem_t sem;

---------------------> //  IP4_ADDR(&ipaddr, 192,168,0,2);

  IP4_ADDR(&ipaddr, 127,0,0,1);

  conn = netconn_new(NETCONN_TCP);
  netconn_bind(conn, &ipaddr, 7);
  netconn_connect(conn, &ipaddr, 7);

  data[0] = 'h';
  data[1] = 'o';
  data[2] = 'l';
  data[3] = 'a';
  data[4] = '\0';

  printf("Echo client sending: %s\n",data);
  netconn_write(conn,data,5,NETCONN_COPY);
  netconn_delete(conn);

  // block forever
  sem = sys_sem_new(0);
  sys_sem_wait(sem);
}

It works right now because it is using loopif to send data (tcpecho answers);
but if I replace the line:

IP4_ADDR(&ipaddr, 127,0,0,1) 

for this one:

IP4_ADDR(&ipaddr, 192,168,0,2)

wich means that data should be sent to tapif it doesn't work.

Does anyone know what is wrong????
May I have to do some other initialization???

Thanks.



[This message was sent through the lwip discussion list.]




reply via email to

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