void close() {
        closing = true;

        try {
            socket.close();
        } catch(IOException e) {
            throw new RuntimeException(e);
        }

        server.connectionClosed(this);
    }