Tcp programming under linux

just learned tcp programming under linux, and just successfully implemented a simple backfire client-server.

but there is a question: when the client finishes sending the file, it needs close (fd), so how can I tell the server that you can also close it?

my idea is to manually pass a special string to tell the server that you can also close, but I don"t know if this idea is correct?

Mar.06,2021

is actually not necessary to pass it manually. When the client calls close, the server will read EOF, and the server can close (if you no longer send data to the client)


after calling close, the client will send a FIN packet to the server, and the server ACK will also send a FIN packet to the client. The client will formally end the connection after sending ACK again. You do not need any additional operations in the application layer.
but: you only end this connection. In tcp, it is important to mark a connection as a quad (source address, source port, destination address, destination port), not to shut down the entire server .

Menu