For example we have a client-server application. If the server writes a message on the socket and then closes it before the client's read. Will the client be able to read the message?
"If the server writes a message on the socket and then closes it before the client's read. Will the client be able to read the message?"
Yes. The client will get the data that was sent before the FIN packet that closes the socket.