Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

LWIP: Simple client example

Altera_Forum
Honored Contributor II
1,885 Views

Hi all, 

I have tried successfully LWIP standalone downloaded from  

And I tried to write simple program using LWIP stand alone to receive data from PC. My program just try to connect to server run on PC and then receive data sent by that server. 

 

static err_t 

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

char *data; 

............ 

return ERR_OK; 

/*-----------------------------------------------------------------------------------*/ 

static err_t 

receiver_connected( void *arg, struct tcp_pcb *pcb, err_t err) 

u16_t len; 

err_t error; 

struct receiver_state *rcvs; 

 

printf("\nerr %d\n", err); 

 

char *init = "GET"; 

len = strlen( init); 

rcvs = mem_malloc(sizeof(struct receiver_state)); 

if( rcvs == NULL) 

printf("\nMalloc error"); 

return ERR_MEM; 

 

rcvs->len = 0; 

 

if( err == ERR_OK) 

printf("\nWow! We have been connecting"); 

 

tcp_arg( pcb, rcvs); 

 

error = tcp_write( pcb, init, len, 0); 

 

tcp_sent( pcb, receiver_sent); 

 

tcp_recv( pcb, receiver_recv); 

 

tcp_err( pcb, receiver_err); 

 

tcp_poll( pcb, receiver_poll, 10); 

 

return ERR_OK; 

else 

return err; 

/*-----------------------------------------------------------------------------------*/ 

void 

receiver_init(void) 

int i; 

struct tcp_pcb *pcb; 

 

IP4_ADDR(&remote_addr, IPADDR0, IPADDR1, IPADDR2, IPADDR3); 

 

pcb = tcp_new(); 

if( pcb == NULL) 

printf("\nNot enough memory to create new connection\n"); 

return ERR_MEM; 

 

printf("\nCreat pcb successfully"); 

 

err = tcp_connect( pcb, &remote_addr, REMOTE_PORT, receiver_connected); 

 

if( err == ERR_OK) 

.... 

else if ( err = ERR_MEM) 

.... 

else 

...... 

 

But I found that it never go to receiver_connected function! Because I've just tried with LWIP standalone a little, while I am still trying to find errors, I'd like to ask if someone could show me where I am wrong? Or if you have any (simple) client example using LWIP standalone, could you please post here or send me by email? hoangviet5012001@yahoo.com

 

Thanks for your help! 

Viet.
0 Kudos
0 Replies
Reply