Java 8 InetSocketAddress - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 InetSocketAddress class.

This code example shows how to use the following methods:getHostString, getPort
        Node node = this.nodes.get(address);
        if (node != null) return node;
 
        Channel channel = this.channel.getValue();
        IpAddress ipAddress = (IpAddress) channel.down(new Event(Event.GET_PHYSICAL_ADDRESS, address));
        InetSocketAddress socketAddress = new InetSocketAddress(ipAddress.getIpAddress(), ipAddress.getPort());
        String name = channel.getName(address);
        if (name == null) {
            name = String.format("%s:%s", socketAddress.getHostString(), socketAddress.getPort());
        } 
        node = new AddressableNode(address, name, socketAddress);
        Node existing = this.nodes.putIfAbsent(address, node);
        return (existing != null) ? existing : node;
    } 
 
    @Override 
    public ChannelNodeFactory getValue() { 
        return this;
    } 
 
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        //#manager 
        final ActorRef udp = UdpConnected.get(system).manager();
        //#manager 
        //#connect 
        final InetSocketAddress remoteAddr =
            new InetSocketAddress("127.0.0.1", 12345);
        udp.tell(UdpConnectedMessage.connect(handler, remoteAddr), getSelf());
        //#connect 
        //#connect-with-options 
        final InetSocketAddress localAddr =
            new InetSocketAddress("127.0.0.1", 1234);
        final List<Inet.SocketOption> options =
            new ArrayList<Inet.SocketOption>();
        options.add(UdpSO.broadcast(true));
        udp.tell(UdpConnectedMessage.connect(handler, remoteAddr, localAddr, options), getSelf());
        //#connect-with-options 
      } else 
        //#connected 
        if (msg instanceof UdpConnected.Connected) {
          final UdpConnected.Connected conn = (UdpConnected.Connected) msg;
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getHostName, getPort
    } 
  } 
 
   
  private void testPbClientFactory() { 
    InetSocketAddress addr = new InetSocketAddress(0);
    System.err.println(addr.getHostName() + addr.getPort());
    Configuration conf = new Configuration();
    LocalizationProtocol instance = new LocalizationProtocolTestImpl();
    Server server = null;
    try { 
      server = 
        RpcServerFactoryPBImpl.get().getServer( 
            LocalizationProtocol.class, instance, addr, conf, null, 1);
      server.start();
      System.err.println(server.getListenerAddress());
      System.err.println(NetUtils.getConnectAddress(server));
 
      try { 
        LocalizationProtocol client = (LocalizationProtocol)
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    InetSocketTransportAddress() { 
 
    } 
 
    public InetSocketTransportAddress(String hostname, int port) {
        this(new InetSocketAddress(hostname, port));
    } 
 
    public InetSocketTransportAddress(InetAddress address, int port) {
        this(new InetSocketAddress(address, port));
    } 
 
    public InetSocketTransportAddress(InetSocketAddress address) {
        this.address = address;
    } 
 
    public static InetSocketTransportAddress readInetSocketTransportAddress(StreamInput in) throws IOException {
        InetSocketTransportAddress address = new InetSocketTransportAddress();
        address.readFrom(in);
        return address;
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        DatagramSocket socket1 = new DatagramSocket();
        DatagramSocket socket2 = new DatagramSocket();
        DatagramSocket socket3 = new DatagramSocket();
        DatagramSocket socket4 = new DatagramSocket();
        InetAddress localhost = InetAddress.getLocalHost();
        SocketAddress socketAddress = new InetSocketAddress(localhost, 1);
 
        when(this.factory.createDatagramSocket("test")).thenReturn(socket1);
        when(this.factory.createDatagramSocket("test", 1)).thenReturn(socket2);
        when(this.factory.createDatagramSocket("test", socketAddress)).thenReturn(socket3);
        when(this.factory.createDatagramSocket("test", 1, localhost)).thenReturn(socket4);
 
        DatagramSocket result1 = this.subject.createDatagramSocket("test");
        DatagramSocket result2 = this.subject.createDatagramSocket("test", 1);
        DatagramSocket result3 = this.subject.createDatagramSocket("test", socketAddress);
        DatagramSocket result4 = this.subject.createDatagramSocket("test", 1, localhost);
 
        verify(this.manager.getUnnamedRegistry()).registerSocket(socket1);
        verify(this.manager.getUnnamedRegistry()).registerSocket(socket2);
        verify(this.manager.getUnnamedRegistry()).registerSocket(socket3);
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getHostName, getPort
    /** 
     * Creates a ServerAddress with default port 
     * @param addr host address 
     */ 
    public ServerAddress( InetAddress addr ){
        this( new InetSocketAddress( addr , defaultPort() ) );
    } 
 
    /** 
     * Creates a ServerAddress 
     * @param addr host address 
     * @param port mongod port 
     */ 
    public ServerAddress( InetAddress addr , int port ){
        this( new InetSocketAddress( addr , port ) );
    } 
 
    /** 
     * Creates a ServerAddress 
     * @param addr inet socket address containing hostname and port 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getHostName, getPort
    } 
  } 
 
   
  private void testPbClientFactory() { 
    InetSocketAddress addr = new InetSocketAddress(0);
    System.err.println(addr.getHostName() + addr.getPort());
    Configuration conf = new Configuration();
    ApplicationMasterProtocol instance = new AMRMProtocolTestImpl();
    Server server = null;
    try { 
      server = 
        RpcServerFactoryPBImpl.get().getServer( 
            ApplicationMasterProtocol.class, instance, addr, conf, null, 1);
      server.start();
      System.err.println(server.getListenerAddress());
      System.err.println(NetUtils.getConnectAddress(server));
 
      ApplicationMasterProtocol amrmClient = null;
      try { 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getAddress, getPort
        this.address = address;
    } 
 
    @Override 
    public boolean preferred(Node node) {
        return node.getSocketAddress().getAddress().getHostAddress().equals(this.address.getAddress().getHostAddress()) && (node.getSocketAddress().getPort() == this.address.getPort());
    } 
} 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
  public ZKServer(File dataDir, File logDir, int port, boolean erase) throws IOException
  { 
    _dataDir = dataDir;
    _logDir = logDir;
    _zk = new ZooKeeperServer(dataDir, logDir, 5000);
    _factory = new NIOServerCnxn.Factory(new InetSocketAddress(port));
    _erase = erase;
 
  } 
 
  public int getPort() 
  { 
    return _factory.getLocalPort();
  } 
 
  public void startup() throws IOException, InterruptedException 
  { 
    ensureDir(_dataDir);
    ensureDir(_logDir);
    _zk.startup();
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
  public void preStart() throws Exception { 
    //#manager 
    final ActorRef tcpManager = Tcp.get(getContext().system()).manager(); 
    //#manager 
    tcpManager.tell( 
        TcpMessage.bind(getSelf(), new InetSocketAddress("localhost", 0), 100), 
        getSelf()); 
  } 
 
  @Override 
  public void postRestart(Throwable arg0) throws Exception { 
    // do not restart 
    getContext().stop(getSelf()); 
  } 
 
  @Override 
  public void onReceive(Object msg) throws Exception { 
    if (msg instanceof Bound) { 
      log.info("listening on [{}]", ((Bound) msg).localAddress()); 
    } else if (msg instanceof Tcp.CommandFailed) { 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Java 8 InetSocketAddress Questions & Answers:

See Code Examples for Java 8 InetSocketAddress Methods: