C
C
ChymeNik2016-02-08 01:02:07
C++ / C#
ChymeNik, 2016-02-08 01:02:07

How to close socket (TCP) completely?

After the call

shutdown(tcp->sockfd, SHUT_RDWR);
close(tcp->sockfd);

the socket remains in the FIN_WAIT2 state for a long time (I look in TcpView)
Is it possible to close it completely?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Dubrovin, 2016-02-08
@ChymeNik

Set the setsockopt() option to SO_LINGER with a zero or small timeout before closing the socket.

P
Peter, 2016-02-08
@petermzg

Do so

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question