Fixed bug : return error during a writing when a socket is closed