Hi, You made a common mistake. Let me explain.
When you create the server you get a PCB. This PCB is related to the established server but it is not the one you get at the accept call back. What you need to do is save the PCB from the server creation, in a global variable. At the accept function after you finish defining your new connection meaning assigned all your call back's to the new pcb ... than call tcp_accepted(Global_PCB). I hope that clears the error. Have a nice weekend, Noam. -----Original Message----- From: [email protected] on behalf of CHASE CHENG Sent: Fri 5/10/2013 12:08 PM To: [email protected] Subject: [lwip-users] where should I call tcp_accepted? Hi, I refered the flow of the page (http://lwip.wikia.com/wiki/Raw/TCP), which said that I should call tcp_accepted once an connection is accepted. I added the tcp_accepted in my tcp_accept callback function, but it shows fail since pcb->state is already changed to ESTABLISHED. I wondered where should I call tcp_accepted? Regards, Chase Here is part of the code: static err_t netio_accept(void *arg, struct tcp_pcb *pcb, err_t err) { ... tcp_accepted(pcb); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I tried to add tcp_accepted here. tcp_arg(pcb, ns); tcp_sent(pcb, netio_sent); tcp_recv(pcb, netio_recv); tcp_poll(pcb, netio_poll, 4); /* every 2 seconds */ return ERR_OK; } void netio_init(void) { struct tcp_pcb *pcb; int err; pcb = tcp_new(); do{ err = tcp_bind(pcb, IP_ADDR_ANY, 18767); tx_thread_sleep(500); printf("tcp_bind status: %d\n", err); }while(err != ERR_OK); netio_closed = 0; pcb = tcp_listen(pcb); tcp_accept(pcb, netio_accept); } ************************************************************************************ This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. ************************************************************************************ ************************************************************************************ This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. ************************************************************************************
<<winmail.dat>>
_______________________________________________ lwip-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/lwip-users
