lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] LwIP TCP Server crashes after two accepted connections


From: julian-bauer
Subject: Re: [lwip-users] LwIP TCP Server crashes after two accepted connections simultaneously
Date: Mon, 18 Feb 2019 23:56:09 -0700 (MST)

Hello Sergio,
thanks for first reply.

I'm using LwIP in combination with an zynq FPGA in Xilinx Vivado / SDK.

the error message is a sinple printf(), but I think it is a sideeffect of an
other problem which one occures in high memory consumption and that leads
into the message with the recv_handler...

ok I fotgot to return ERR_ABRT in case of useing tcp_abort() but this
happens not very often, I try to close the tpcb and if I dont get ERR_OK
then I abort it:

if (pcb != NULL) {
        tcp_recv(pcb, NULL);
        tcp_err(pcb, NULL);
        err = tcp_close(pcb);
        if (err != ERR_OK) {
                /* Free memory with abort */
                tcp_abort(pcb);
                return ERR_ABRT;
        }
        else
        {
                return ERR_OK; //err_t;
        }
}

In my recv callbeck I first check for if(!p); then I call 
tcp_recved(tpcb, p->tot_len); 
pbuf_free(p);

and then I do a tcp_write() without tcp_output(), this is the answer to my
hello message (only the first time, not every time I recv any message!)
I store the received data in a RxBuffer with RxHead and RxTail. Then I call
my internal protocoll routine (not in the callback funktion but in my
TransportHandler() ) that generates the answer message in TxBuffer with
TxHead and TxTail and if I have data to send, I send them with tcp_write()
and tcp_output()
I dont have a send_callback(), what should I do in this callback function?

I call tcp_close and if needed tcp_abort also in the error_callback() if I
get 
(err == ERR_ABRT || err == ERR_RST || err == ERR_CLSD)
and I get the tpcb from the argument, because as an argument I set the
structure of my TransportHandler witch one has an element of pcb inside. So
I have access to my own structure with the pcb as an element in every
callback:
CONNECTION_TYPE *pConn;
pConn = arg;
but if I shouldnt close tcp if I receive an error, what should I do instead
in the err_callback? sending FIN?



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html



reply via email to

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