public long read() throws IOException {
        if (receive == null) {
            receive = new NetworkReceive(maxReceiveSize, id, memoryPool);
        }

        long bytesReceived = receive(this.receive);

        if (this.receive.requiredMemoryAmountKnown() && !this.receive.memoryAllocated() && isInMutableState()) {
            //pool must be out of memory, mute ourselves.
            mute();
        }
        return bytesReceived;
    }
Returns the port to which this channel's socket is connected or 0 if the socket has never been connected.

If the socket was connected prior to being closed, then this method will continue to return the
connected port number after the socket is closed.
clients/src/main/java/org/apache/kafka/common/network/KafkaChannel.java