當前位置: 首頁>>代碼示例>>Java>>正文


Java InetSocketAddress.getAddress方法代碼示例

本文整理匯總了Java中java.net.InetSocketAddress.getAddress方法的典型用法代碼示例。如果您正苦於以下問題:Java InetSocketAddress.getAddress方法的具體用法?Java InetSocketAddress.getAddress怎麽用?Java InetSocketAddress.getAddress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.net.InetSocketAddress的用法示例。


在下文中一共展示了InetSocketAddress.getAddress方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isProviderSide

import java.net.InetSocketAddress; //導入方法依賴的package包/類
/**
 * is provider side.
 * 
 * @return provider side.
 */
public boolean isProviderSide() {
    URL url = getUrl();
    if (url == null) {
        return false;
    }
    InetSocketAddress address = getRemoteAddress();
    if (address == null) {
        return false;
    }
    String host;
    if (address.getAddress() == null) {
        host = address.getHostName();
    } else {
        host = address.getAddress().getHostAddress();
    }
    return url.getPort() != address.getPort() || 
            ! NetUtils.filterLocalHost(url.getIp()).equals(NetUtils.filterLocalHost(host));
}
 
開發者ID:yunhaibin,項目名稱:dubbox-hystrix,代碼行數:24,代碼來源:RpcContext.java

示例2: sendFromNativeBuffer

import java.net.InetSocketAddress; //導入方法依賴的package包/類
private int sendFromNativeBuffer(int fd,
                                 ByteBuffer bb,
                                 SocketAddress target,
                                 int assocId,
                                 int streamNumber,
                                 boolean unordered,
                                 int ppid)
        throws IOException {
    InetAddress addr = null;     // no preferred address
    int port = 0;
    if (target != null) {
        InetSocketAddress isa = Net.checkAddress(target);
        addr = isa.getAddress();
        port = isa.getPort();
    }
    int pos = bb.position();
    int lim = bb.limit();
    assert (pos <= lim);
    int rem = (pos <= lim ? lim - pos : 0);

    int written = send0(fd, ((DirectBuffer)bb).address() + pos, rem, addr,
                        port, assocId, streamNumber, unordered, ppid);
    if (written > 0)
        bb.position(pos + written);
    return written;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:SctpMultiChannelImpl.java

示例3: displayStackTraces

import java.net.InetSocketAddress; //導入方法依賴的package包/類
public boolean displayStackTraces() {
    ServletStackTraces mode = deployment.getDeploymentInfo().getServletStackTraces();
    if (mode == ServletStackTraces.NONE) {
        return false;
    } else if (mode == ServletStackTraces.ALL) {
        return true;
    } else {
        InetSocketAddress localAddress = getExchange().getSourceAddress();
        if(localAddress == null) {
            return false;
        }
        InetAddress address = localAddress.getAddress();
        if(address == null) {
            return false;
        }
        if(!address.isLoopbackAddress()) {
            return false;
        }
        return !getExchange().getRequestHeaders().contains(Headers.X_FORWARDED_FOR);
    }

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:ServletRequestContext.java

示例4: sendFromNativeBuffer

import java.net.InetSocketAddress; //導入方法依賴的package包/類
private int sendFromNativeBuffer(int fd,
                                 ByteBuffer bb,
                                 SocketAddress target,
                                 int streamNumber,
                                 boolean unordered,
                                 int ppid)
        throws IOException {
    InetAddress addr = null;     // no preferred address
    int port = 0;
    if (target != null) {
        InetSocketAddress isa = Net.checkAddress(target);
        addr = isa.getAddress();
        port = isa.getPort();
    }

    int pos = bb.position();
    int lim = bb.limit();
    assert (pos <= lim);
    int rem = (pos <= lim ? lim - pos : 0);

    int written = send0(fd, ((DirectBuffer)bb).address() + pos, rem, addr,
                        port, -1 /*121*/, streamNumber, unordered, ppid);
    if (written > 0)
        bb.position(pos + written);
    return written;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:SctpChannelImpl.java

示例5: isConsumerSide

import java.net.InetSocketAddress; //導入方法依賴的package包/類
/**
 * is consumer side.
 * 
 * @return consumer side.
 */
public boolean isConsumerSide() {
    URL url = getUrl();
    if (url == null) {
        return false;
    }
    InetSocketAddress address = getRemoteAddress();
    if (address == null) {
        return false;
    }
    String host;
    if (address.getAddress() == null) {
        host = address.getHostName();
    } else {
        host = address.getAddress().getHostAddress();
    }
    return url.getPort() == address.getPort() && 
            NetUtils.filterLocalHost(url.getIp()).equals(NetUtils.filterLocalHost(host));
}
 
開發者ID:flychao88,項目名稱:dubbocloud,代碼行數:24,代碼來源:RpcContext.java

示例6: createTest

import java.net.InetSocketAddress; //導入方法依賴的package包/類
public static VirtualServerChannelSelector
createTest(
	InetSocketAddress 								bind_address,
	int 											so_rcvbuf_size,
	VirtualServerChannelSelector.SelectListener 	listener )
{
		// test param to allow multiple ports to be created

	 int	range = COConfigurationManager.getIntParameter( "TCP.Listen.Port.Range", -1 );

	 if ( range == -1 ){

		 return( createBlocking( bind_address, so_rcvbuf_size, listener ));

	 }else{

		 return( new VirtualNonBlockingServerChannelSelector(
				 		bind_address.getAddress(),
				 		bind_address.getPort(),
				 		range,
				 		so_rcvbuf_size, listener ));
	 }
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:24,代碼來源:VirtualServerChannelSelectorFactory.java

示例7: TokenServer

import java.net.InetSocketAddress; //導入方法依賴的package包/類
public TokenServer(Configuration conf) throws IOException {
  this.conf = conf;
  this.startcode = EnvironmentEdgeManager.currentTime();
  // Server to handle client requests.
  String hostname =
    Strings.domainNamePointerToHostName(DNS.getDefaultHost("default", "default"));
  int port = 0;
  // Creation of an ISA will force a resolve.
  InetSocketAddress initialIsa = new InetSocketAddress(hostname, port);
  if (initialIsa.getAddress() == null) {
    throw new IllegalArgumentException("Failed resolve of " + initialIsa);
  }
  final List<BlockingServiceAndInterface> sai =
    new ArrayList<BlockingServiceAndInterface>(1);
  BlockingService service =
    AuthenticationProtos.AuthenticationService.newReflectiveBlockingService(this);
  sai.add(new BlockingServiceAndInterface(service,
    AuthenticationProtos.AuthenticationService.BlockingInterface.class));
  this.rpcServer =
    new RpcServer(this, "tokenServer", sai, initialIsa, conf, new FifoRpcScheduler(conf, 1));
  InetSocketAddress address = rpcServer.getListenerAddress();
  if (address == null) {
    throw new IOException("Listener channel is closed");
  }
  this.isa = address;
  this.sleeper = new Sleeper(1000, this);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:TestTokenAuthentication.java

示例8: getSocketPair

import java.net.InetSocketAddress; //導入方法依賴的package包/類
static Socket[] getSocketPair() throws IOException {
    ServerSocket ss = new ServerSocket();
    ss.bind(null);
    InetSocketAddress endPoint = (InetSocketAddress) ss.getLocalSocketAddress();
    Socket s = new Socket(endPoint.getAddress(), endPoint.getPort());
    return new Socket[] { s, ss.accept() };
}
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:8,代碼來源:Zab1_0Test.java

示例9: isLocalAddress

import java.net.InetSocketAddress; //導入方法依賴的package包/類
public static boolean isLocalAddress(InetSocketAddress targetAddr) {
  InetAddress addr = targetAddr.getAddress();
  Boolean cached = localAddrMap.get(addr.getHostAddress());
  if (cached != null) {
    LOG.trace("Address {} is {} local", targetAddr, (cached ? "" : "not"));
    return cached;
  }

  boolean local = NetUtils.isLocalAddress(addr);

  LOG.trace("Address {} is {} local", targetAddr, (local ? "" : "not"));
  localAddrMap.put(addr.getHostAddress(), local);
  return local;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:15,代碼來源:NuCypherExtUtilClient.java

示例10: TransportAddress

import java.net.InetSocketAddress; //導入方法依賴的package包/類
public TransportAddress(InetSocketAddress address) {
    if (address == null) {
        throw new IllegalArgumentException("InetSocketAddress must not be null");
    }
    if (address.getAddress() == null) {
        throw new IllegalArgumentException("Address must be resolved but wasn't - InetSocketAddress#getAddress() returned null");
    }
    this.address = address;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,代碼來源:TransportAddress.java

示例11: getChannel

import java.net.InetSocketAddress; //導入方法依賴的package包/類
@Override
public Channel getChannel(InetSocketAddress remoteAddress) {
    String host = remoteAddress.getAddress() != null ? remoteAddress.getAddress().getHostAddress() : remoteAddress.getHostName();
    int port = remoteAddress.getPort();
    Channel channel = super.getChannel(remoteAddress);
    if (channel == null) {
        for (Map.Entry<URL, Client> entry : clients.entrySet()) {
            URL url = entry.getKey();
            if (url.getIp().equals(host) && url.getPort() == port) {
                return entry.getValue();
            }
        }
    }
    return channel;
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:16,代碼來源:ServerPeer.java

示例12: getRemoteIp

import java.net.InetSocketAddress; //導入方法依賴的package包/類
public static String getRemoteIp(Channel channel) {
    InetSocketAddress inetSocketAddress = (InetSocketAddress) channel.remoteAddress();
    if (inetSocketAddress == null) {
        return "";
    }
    final InetAddress inetAddr = inetSocketAddress.getAddress();
    return inetAddr != null ? inetAddr.getHostAddress() : inetSocketAddress.getHostName();
}
 
開發者ID:lyy4j,項目名稱:rmq4note,代碼行數:9,代碼來源:ChannelUtil.java

示例13: connectSocket

import java.net.InetSocketAddress; //導入方法依賴的package包/類
public Socket connectSocket(
        final Socket sock,
        final InetSocketAddress remoteAddress,
        final InetSocketAddress localAddress,
        final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
    final String host = remoteAddress.getHostName();
    final int port = remoteAddress.getPort();
    InetAddress local = null;
    int localPort = 0;
    if (localAddress != null) {
        local = localAddress.getAddress();
        localPort = localAddress.getPort();
    }
    return this.factory.connectSocket(sock, host, port, local, localPort, params);
}
 
開發者ID:mozilla-mobile,項目名稱:FirefoxData-android,代碼行數:16,代碼來源:SchemeSocketFactoryAdaptor.java

示例14: getSocketPair

import java.net.InetSocketAddress; //導入方法依賴的package包/類
static Socket[] getSocketPair() throws IOException {
    ServerSocket ss =
        new ServerSocket(0, 50, InetAddress.getByName("127.0.0.1"));
    InetSocketAddress endPoint = (InetSocketAddress) ss.getLocalSocketAddress();
    Socket s = new Socket(endPoint.getAddress(), endPoint.getPort());
    return new Socket[] { s, ss.accept() };
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:8,代碼來源:Zab1_0Test.java

示例15: isAllowed

import java.net.InetSocketAddress; //導入方法依賴的package包/類
/**
 * check that the specified host/ip is allowed
 * @param addr
 * @return
 */
private boolean isAllowed(InetSocketAddress addr) {
	InetAddress address = addr.getAddress();
	if( checkHost(address.getHostAddress()) )
		return true;
	else if( checkHost(address.getHostName()))
		return true;
	else
		return false;
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:15,代碼來源:SocketServer.java


注:本文中的java.net.InetSocketAddress.getAddress方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。