byte[] buffer; int offset = 0; int len = src.remaining();  if (src.hasArray()) { buffer = src.array(); offset = src.arrayOffset() + src.position(); } else { buffer = new byte [len]; src.get (buffer);
return channel.send(src, dst);
  public int send (ByteBuffer src, SocketAddress target)    throws IOException  {    if (!isOpen())      throw new ClosedChannelException();        if (target instanceof InetSocketAddress	&& ((InetSocketAddress) target).isUnresolved())      throw new IOException("Target address not resolved");    byte[] buffer;    int offset = 0;    int len = src.remaining();        if (src.hasArray())      {        buffer = src.array();        offset = src.arrayOffset() + src.position();      }    else      {        buffer = new byte [len];        src.get (buffer);  }        DatagramPacket packet = new DatagramPacket (buffer, offset, len, target);    boolean completed = false;    try  {        begin();        setInChannelOperation(true);        socket.send(packet);        completed = true;      }    finally      {        end (completed);        setInChannelOperation(false);      }          if (src.hasArray())      {	src.position (src.position() + len);      }    return len;  }