0

On the basis of shutdown vs close I have known the difference between shutdown and close.

But which will choose if select timeout in socket, the client will close or shutdown(sock, SHUT_WR).

I try to read the source code of select.c, but it is too hard to read.

Can anyone give me some help.

  • 1
    Neither. If `select()` times out, bothing has happened on the socket at all. No reason to either close or shut it down, unless you are concerned with inactivity timeout. – user207421 Jun 04 '21 at 11:26

1 Answers1

2

But which will choose if select timeout in socket, the client will close or shutdown(sock, SHUT_WR).

If the client has a call to select(), the client can decide what to do when that call times out.

Almost by definition, if your select() times out, it's telling you that nothing happened to the socket (nothing that you told select() you were interested in, anyway).

Sockets don't automatically close (or shutdown) just because nothing happened for a while. You have to do that yourself, if you want it.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Useless
  • 64,155
  • 6
  • 88
  • 132