I want to detect a server-sided socket close (closed by socket.setSoTimeout) by sending data from the client Socket OutputStream (socket.getOutputStream().write(42)). If the Socket is closed on the server-side this should cause an Exception. But it only throws an Exception if I send data twice:
private boolean sendTest() {
    try {
        System.out.print("connection...");
        socket.getOutputStream().write(42); //Sending "*"
        socket.getOutputStream().write(42); //not working without this line
        System.out.println("ok");
        return true;
    } catch (IOException e) {
        System.out.println("error...disconnecting socket");
        disconnect();
        return false;
    }
}
How can you explain this behaviour?