-2

I tried server client tcp code in c, I want to add some functionality to disconnect client from server. I search on google for it. I found function shutdown(), I am not getting idea how to do it ?

Robert
  • 5,278
  • 43
  • 65
  • 115
Gresa44
  • 3
  • 1
  • 2

1 Answers1

4

To disconnect a client from the server, just close the fd linked to this client. To disconnect a client to a server from the client, just close the client socket.

This is a quick way to disconnect, but don't forget to send a last exit message when you are leaving from a server / disconnecting a client.

No need of shutdown here. (Except if you share fd between processes, but without more information we cannot be more precise)

Aracthor
  • 5,757
  • 6
  • 31
  • 59