Active close vs passive close


#1

Hi,

How do we chose active close or passive close ?

Best regards


#2

Hi, thierrydollar.

If you command close, it is active close.
If you receive FIN packet, it is passive close.

Best regards.


#3

Hi thierrydollar,

I’d like add some explanation to above reply.
As you know, socket close happens by 3 way handshake.

When any device A requests to close the specific socket first, we call it Device A does [color=#FF0000]ACTIVE CLOSE[/color].
When any device B, which communicates with or stays in idle, receives FIN packet from its peer, we call it Device B does [color=#FF0000]PASSIVE CLOSE[/color].

We can just call close() function in sock_established status, for active close.

Otherwise, if the status of its corresponding socket changed to sock_closewait, this means your device received FIN packet from its peer.
Your device is already in passive close stage.
In this case, if you don’t have any data to be processed then call close().
It makes that socket closed gracefully.

I hope my post will help you.

Thanks.

javakys.