security against write on closed sockets