Mercurial > lbo > hg > clusterrpc-java
view src/main/java/net/borgac/clusterrpc/client/PeerAddress.java @ 5:117cb812e28a
Implement several lower-level classes (networking/framing)
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Fri, 23 Sep 2016 22:01:17 +0200 |
parents | |
children | 0e608c466a58 |
line wrap: on
line source
package net.borgac.clusterrpc.client; import java.net.InetSocketAddress; /** * PeerAddress identifies a remote server that a ClientChannel can connect to. * * @author lbo */ public class PeerAddress { private final String host; private final int port; /** * Construct a PeerAddress from a (host,port) tuple. * * @param host * @param port */ public PeerAddress(String host, int port) { this.host = host; this.port = port; } /** * Construct a PeerAddress from an InetSocketAddress. * * @param address Address to use (note: InetSocketAddress performs a host * lookup!) */ public PeerAddress(InetSocketAddress address) { this.host = address.getHostString(); this.port = address.getPort(); } String getConnectAddress() { return String.format("tcp://%s:%d", host, port); } }