if (!isOpen()) throw new ClosedChannelException();  if (isConnected()) throw new AlreadyConnectedException();  if (connectionPending) throw new ConnectionPendingException();  if (!(remote instanceof InetSocketAddress)) throw new UnsupportedAddressTypeException();  if (((InetSocketAddress) remote).isUnresolved()) throw new UnresolvedAddressException();  try { socket.getPlainSocketImpl().setInChannelOperation(true);     if (isBlocking()) {  socket.connect (remote); return true;
return connect(remote, 0);
  public boolean connect (SocketAddress remote) throws IOException  {    if (!isOpen())      throw new ClosedChannelException();        if (isConnected())      throw new AlreadyConnectedException();	    if (connectionPending)      throw new ConnectionPendingException();	    if (!(remote instanceof InetSocketAddress))      throw new UnsupportedAddressTypeException();	    if (((InetSocketAddress) remote).isUnresolved())      throw new UnresolvedAddressException();        try	    {        socket.getPlainSocketImpl().setInChannelOperation(true);          // indicate that a channel is initiating the accept operation          // so that the socket ignores the fact that we might be in          // non-blocking mode.        if (isBlocking())          {            // Do blocking connect.            socket.connect (remote);            return true;  }            // Do non-blocking connect.        try  {            socket.connect (remote, NIOConstants.DEFAULT_TIMEOUT);            return true;          }        catch (SocketTimeoutException e)          {            connectionPending = true;    return false;  }      }    finally      {        socket.getPlainSocketImpl().setInChannelOperation(false);      }  }