[Top][All Lists]

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

[lwip-users] Correct method to close a TCP connection ( both listning an

From: Arvind NR
Subject: [lwip-users] Correct method to close a TCP connection ( both listning and connected pcb's ).
Date: Mon, 8 Oct 2012 18:35:22 +0200

Hello Every One

I had an important question regarding the closing of a TCP connection. I am working with RAW APIs and I have to implement the following functionality in my application :

1) I am listening on a port and once the connection is accepted I should not be able to accept any more connections on that port. So its just one connection per port!
2) For a reset mechanism in my application I have to implement a kill socket like method so I have to close any connected tcp connections.

The method I have adopted so far is as follows :
1) As soon as I get a connection on my listen pcb and it enters the accept call back function , I close the listening pcb by using tcp_close(listning_pcb). This way its not possible to make another connection to the listening pcb
2) If I have to close the conneced tcp pcb's I make use of the function tcp_abort(connected_pcb).

Is this the correct way of doing it? I dont want to run into problems of memory leaks due to faulty deallocating of the concerned PCB's.

 In one of the example templates of a receive call back function I have seen that the function tcp_recv(connected_pcb, NULL) is called after a tcp_close(conected_pcb) is called. Why is the tcp_recv() called after a tcp_close() ??? Can any one explain this small doubt.

Any help is greatly appreciated


We are what we repeatedly do. Excellence, then, is not an act, but a habit - Aristotle

reply via email to

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