Hy..I've seen in the tutorial that client side disconnect is called simply by a break in the read loop. I would like to know which is the step-by-step instruction to close correctly a TCP connection (both server and client side) and where I have to put them. I've seen the close and shutdown functions, but I don't know where call them.
It depends on the structure of your code and on what you do exactly. For example, if you've got a chain "send-handler-send-...", and you use shared_from_this idiom, and this chain ends at some stage of your program -- you shouldn't do anything more, as your connection object along with its socket will destroy & close automatically, thanks to the shared_from_this idiom. OTOH, if your chain is "infinite", eg. it's a receiving socket, which should always be listening for incoming data -- then you should close it explicitly by calling socket.close().
Finally...what I can do when an EOF error happens??
It means that the connection has been closed.