lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] restarting a connection with the raw api


From: Richie Bonventre
Subject: Re: [lwip-users] restarting a connection with the raw api
Date: Sun, 4 Sep 2011 00:08:19 -0400

Hey thanks for helping out.
It doesn't seem quite so straightforward as that. For example suppose
you connect and then unplug the cable. If you try and tcp_close() and
the other computer is no longer connected, the connection doesnt
actually end because the close request is never acked and everything
will get messed up if you just try and tcp_connect again. I've had
problems where if you call tcp_new() or tcp_connect() at the wrong
time, it will overwrite the current connection and repush it on to
tcp_active_pcbs which causes pcb->next to point to itself. This causes
lots of the lwip timers and functions to loop forever and freeze the
code. Other times, even if the other computer is still connected and
the closing is completely acked and everything, when you try and
tcp_connect again on the same connection, it no longer seems to get
any response from the other computer. It seems like even though the
connection makes it all the way to the CLOSED state, the other
computer isn't completely aware that the connection is done and wont
accept another request from the same connection.

I'm basically trying to account for 4 situations:
1 - A connection is established from lwip to some code on another
machine, and then I ctrl-C the code listening on the other machine. I
want lwip to recognize this and try to reconnect, to be ready whenever
I restart the listener on B.
2 - I attempt to connect but the cable is not plugged in between the machines.
3 - I attempt to connect and the cable is plugged in, but nothing is
listening to the socket yet to accept the connection on the other
machine.
4 - I have connected successfully, and I then unplug the cable. My
code that uses lwip periodically sends a ping packet, and if it
doesn't get a response in time, it should close the connection and try
to reconnect.

So for which of these do I have to call tcp_close(), which can I
recall tcp_new() or should I reuse the old tcp_pcb, and what do I need
to monitor before I call either of these or call tcp_connect() again?
Do I need to be checking the state of the pcb or something else?
thanks,
RB



reply via email to

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