InetSocketAddress isUnresolved - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for InetSocketAddress isUnresolved method.

This code example shows how to use the following methods:getAddress, getHostName, getPort, isUnresolved
          throws IOException { 
 
        assert (addr instanceof InetSocketAddress);
        InetSocketAddress iaddr = (InetSocketAddress) addr;
        SocketAddress newAddr = null;
        if (iaddr.isUnresolved())
          newAddr =
              new InetSocketAddress(iaddr.getHostName(),
                  iaddr.getPort() - 10);
        else 
          newAddr =
              new InetSocketAddress(iaddr.getAddress(), iaddr.getPort() - 10);
        System.out.printf("Test socket: rerouting %s to %s\n", iaddr,
            newAddr);
        super.connect(newAddr, timeout);
      } 
    }; 
  } 
 
  /* @inheritDoc */ 
7
CodeRank
This code example shows how to use the following methods:getAddress, isUnresolved
    protected String getHost(InetSocketAddress isa) {
 
        //@@@ Will this work with literal IPv6 addresses, or do we 
        //@@@ need to wrap these in [] for the string representation? 
        //@@@ Having it in this method at least allows for easy workarounds. 
       return isa.isUnresolved() ?
            isa.getHostName() : isa.getAddress().getHostAddress();
  
    } 
 
 
    /* 
     * Chooses a proxy from a list of available proxies. 
     * The default implementation just picks the first non-SOCKS proxy 
     * from the list. If there are only SOCKS proxies, 
     * {@link Proxy#NO_PROXY Proxy.NO_PROXY} is returned. 
     * Derived classes may implement more advanced strategies, 
     * such as proxy rotation if there are multiple options. 
     * 
     * @param proxies   the list of proxies to choose from, 
6
CodeRank
This code example shows how to use the following methods:getAddress, getPort, isUnresolved
        } 
    } 
 
    @Override 
    protected void connect(String remoteHost, int port) throws IOException {
        connect(new InetSocketAddress(remoteHost, port), 0);
    } 
 
    @Override 
    protected void connect(InetAddress remoteAddress, int port) throws IOException {
        connect(new InetSocketAddress(remoteAddress, port), 0);
    } 
 
    /** 
     * Connects the Socket to the specified remoteAddress. 
     *  
     * @param   remoteAddress     the <code>SocketAddress</code> to connect to. 
     * @param   timeoutInMs       the timeout value in milliseconds, or zero for no timeout. 
     * @throws  IOException       if the connection can't be established. 
     * @throws  IllegalArgumentException if remoteAddress is null or a 

6
CodeRank
This code example shows how to use the following methods:getAddress, getHostName, getPort, isUnresolved
                throw new HttpException
                    ("Unable to handle non-Inet proxy address: "+p.address());
            } 
            final InetSocketAddress isa = (InetSocketAddress) p.address();
            // assume default scheme (http) 
            result = new HttpHost(getHost(isa), isa.getPort());
        } 
 
        return result;
    } 
 
    /** 
     * Obtains a host from an {@link InetSocketAddress}. 
     * 
     * @param isa       the socket address 
     * 
     * @return  a host string, either as a symbolic name or 
     *          as a literal IP address string 
     * <br/> 
     * (TODO: determine format for IPv6 addresses, with or without [brackets]) 

6
CodeRank
This code example shows how to use the following methods:getAddress, getHostName, getPort, isUnresolved
                throw new HttpException
                    ("Unable to handle non-Inet proxy address: "+p.address());
            } 
            final InetSocketAddress isa = (InetSocketAddress) p.address();
            // assume default scheme (http) 
            result = new HttpHost(getHost(isa), isa.getPort());
        } 
 
        return result;
    } 
 
    /** 
     * Obtains a host from an {@link InetSocketAddress}. 
     * 
     * @param isa       the socket address 
     * 
     * @return  a host string, either as a symbolic name or 
     *          as a literal IP address string 
     * <br/> 
     * (TODO: determine format for IPv6 addresses, with or without [brackets]) 

6
CodeRank
This code example shows how to use the following methods:getAddress, getHostName, getPort, isUnresolved
                throw new HttpException
                    ("Unable to handle non-Inet proxy address: "+p.address());
            } 
            final InetSocketAddress isa = (InetSocketAddress) p.address();
            // assume default scheme (http) 
            result = new HttpHost(getHost(isa), isa.getPort());
        } 
 
        return result;
    } 
 
    /** 
     * Obtains a host from an {@link InetSocketAddress}. 
     * 
     * @param isa       the socket address 
     * 
     * @return  a host string, either as a symbolic name or 
     *          as a literal IP address string 
     * <br/> 
     * (TODO: determine format for IPv6 addresses, with or without [brackets]) 

6
CodeRank
This code example shows how to use the following methods:getAddress, getHostName, getPort, isUnresolved
    proxy_listener 		= _listener;
    socks_version		= _socks_version;
    socks_user			= _socks_user;
    socks_password		= _socks_password;
        
    if ( remote_address.isUnresolved() || remote_address.getAddress() == null ){
      // deal with long "hostnames" that we get for, e.g., I2P destinations 
    	mapped_ip = AEProxyFactory.getAddressMapper().internalise( remote_address.getHostName() ); 
    } 
    else{ 
    	mapped_ip = remote_address.getAddress().getHostName();
    } 
     
    if( socks_version.equals( "V4" ) ) {
      try{ 
        doSocks4Login( createSocks4Message() ); 
      } 
      catch( Throwable t ) {
        Debug.out( t );
        proxy_listener.connectFailure( t );

5
CodeRank
This code example shows how to use the following methods:getHostName, isUnresolved
        if (address == null) {
            return; 
        } 
        if (address instanceof InetSocketAddress) {
            final InetSocketAddress endpoint = (InetSocketAddress) address;
            if (endpoint.isUnresolved()) {
                throw new UnknownHostException(endpoint.getHostName());
            } 
        } 
    } 
 
    private void processSessionRequests() throws IOReactorException { 
        SessionRequestImpl request;
        while ((request = this.requestQueue.poll()) != null) {
            if (request.isCompleted()) {
                continue; 
            } 
            final SocketChannel socketChannel;
            try { 
                socketChannel = SocketChannel.open();
5
CodeRank
This code example shows how to use the following methods:isUnresolved
    if (!(remote instanceof InetSocketAddress))
      throw new UnsupportedAddressTypeException();
 
    connectAddress = (InetSocketAddress) remote;
 
    if (connectAddress.isUnresolved())
      throw new UnresolvedAddressException();
 
    connected = channel.connect(connectAddress, timeout);
    connectionPending = !connected;
    return connected;
  } 
 
  public boolean finishConnect() 
    throws IOException 
  { 
    if (!isOpen())
      throw new ClosedChannelException();
 
    InetSocketAddress remote = channel.getPeerAddress();
5
CodeRank
This code example shows how to use the following methods:getHostName, getPort, isUnresolved
            SocketAddress socketAddress = socketAddresses[nextSocketAddressIndex];
 
            // QFJ-266 Recreate socket address for unresolved addresses 
            if (socketAddress instanceof InetSocketAddress) {
                InetSocketAddress inetAddr = (InetSocketAddress) socketAddress;
                if (inetAddr.isUnresolved()) {
                    socketAddress = new InetSocketAddress(inetAddr.getHostName(), inetAddr
                            .getPort());
                    socketAddresses[nextSocketAddressIndex] = socketAddress;
                } 
            } 
            nextSocketAddressIndex = (nextSocketAddressIndex + 1) % socketAddresses.length;
            return socketAddress;
        } 
 
        private boolean shouldReconnect() { 
            return (ioSession == null || !ioSession.isConnected()) && isTimeForReconnect()
                    && (fixSession.isEnabled() && fixSession.isSessionTime());
        } 
         
5
CodeRank
isUnresolved Method Overview
Returns whether this socket address is unresolved or not.
See Code Examples for other Java 8 InetSocketAddress Methods: