lwip-devel
[Top][All Lists]
Advanced

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

Re: [lwip-devel] Simple data transfer with lwip


From: RedCollarPanda
Subject: Re: [lwip-devel] Simple data transfer with lwip
Date: Mon, 23 Jun 2014 00:34:26 -0700 (PDT)

Sorry for asking, but... Lets say I have a netcat server, that replyes me(in
cinsole) all I'm sending - 

ncat -v -l -p 5555 -c 'while true; do read i && echo [echo] $i; done' 

Can you give simple example of client that will send something to this
server? (using raw api)

I have this client now - 

lwip_init();
u8_t *state;
err_t err;
struct tcp_pcb *pcb;
struct ip_addr ipaddr;
IP4_ADDR(&ipaddr, 127,0,0,1);
if ((state = mem_malloc(1)) == NULL) {
 return ERR_MEM;
}

*state = 1;
if ((pcb = tcp_new()) == NULL)  {
   mem_free(state);
   return ERR_MEM;
}
tcp_arg(pcb, state);
tcp_err(pcb, hello_err);
tcp_recv(pcb, hello_recv);
tcp_sent(pcb, NULL);
tcp_poll(pcb, hello_poll_close, 10);
//
tcp_bind(pcb,&ipaddr, 5555);
//
err = tcp_connect(pcb, &ipaddr, 5555, hello_connected);
if (err != ERR_OK)  {
 std::cout << "err =  " << err << std::endl;
 std::cout << "err =  " << (int)err << std::endl;
 mem_free(state);
 tcp_abort(pcb);                
}





--
View this message in context: 
http://lwip.100.n7.nabble.com/Simple-data-transfer-with-lwip-tp22803p22815.html
Sent from the lwip-devel mailing list archive at Nabble.com.



reply via email to

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