f socket refers to an open TCP connection, the connection is closed. If a stream socket is closed when there is input data queued, the TCP connection is reset rather than being cleanly closed. The descriptor of the socket to be closed
To close the socket you need to call shutdown() first and then close(), and shutdown takes an argument