Hi, I am not sure I understand your problem but if I did understand, you please see below.
In RAW mode you have just one task that runs all your TCP/IP connections and servers. One task means that every time you do something related to TCP only this part is running And nothing else is working. LwIP has its own house housekeeping operations (ACK, SYN, etc.....). When you get a packet dedicated to your server, your own call back is triggered. You process the data and call tcp_write tcp_write adds a buffer to the list of buffers to be sent. But and here comes the BIG but. The code that is sending the data (inside LwIP) will never be called if you do not exit from your own function and let the stack do its housekeeping tasks. You cannot expect the data to be sent at zero delay after you put it to be sent. I hope now it is clear. BR, Noam. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Valery Ushakov Sent: ב 12 אוגוסט 2013 22:40 To: [email protected] Subject: Re: [lwip-users] tcp_output() when processing "tcp_input_pcb" Numb_Faith <[email protected]> wrote: > When I use lwip1.4.1 and RAW API, I meet a problem. I use my > borad(STM32) as a server. When server receive a packet from client, I > hope it can send a packet immediately. So I call the function below: > > /tcp_write(tpcb, DataTest, sizeof(DataTest), 0x01); tcp_output(tpcb);/ > > But when server receive a packet, the stack will call tcp_input(), and > tcp_input_pcb = pcb (the connection), so tcp_output(tpcb) would return. > > When I comment the code below(in function tcp_output), it can got what > I want. But I'm still confused about why "If we are invoked by the TCP > input processing code, we do not output anything". > > /* First, check if we are invoked by the TCP input processing code. If > so, we do not output anything. > Instead, we rely on the input processing code to call us when input > processing is done with. */ // if (tcp_input_pcb == pcb) { // return > ERR_OK; // } Input processing code _does_ call tcp_output() at: http://git.savannah.gnu.org/cgit/lwip.git/tree/src/core/tcp_in.c?h=DEVEL-1_4_1#n381 tcp_input_pcb = NULL; /* Try to send something out. */ tcp_output(pcb); At that point input processing is complete and pcb is in consistent state, etc, etc, so tcp_output() doesn't have to be concerned with possible iteractions with tcp_input(). -uwe _______________________________________________ lwip-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/lwip-users ************************************************************************************ 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. ************************************************************************************ _______________________________________________ lwip-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/lwip-users
