Code example for ClosedChannelException

0
        // Same technique is used everywhere in this class where mSocket member 
        // is touched. 
        LocalSocket socket = mSocket;
        if (socket == null) {
            Logw("'send' request on closed Socket " + mChannelName);
            throw new ClosedChannelException();
        } 
        socket.getOutputStream().write(data);
    } 
 
    /** 
     * Sends data to the socket. 
     * 
     * @param data Data to send. 
     * @param offset The start position in data from where to get bytes. 
     * @param len The number of bytes from data to write to this socket. 
     * @throws IOException 
     */ 
    public void send(byte[] data, int offset, int len) throws IOException {
        LocalSocket socket = mSocket;