public Builder address(SocketAddress address) { if (address instanceof InetSocketAddress) { InetSocketAddress inetAddress = (InetSocketAddress) address; ip(inetAddress.getAddress()); port(inetAddress.getPort()); } else { throw new IllegalArgumentException("Unknown type of address: " + address.getClass()); } return this; }
int port = Integer.valueOf(line.substring(portIndex + 1)); for (InetAddress inetAddress : inetAddresses) { streamSet.add(new NetworkAddress.Builder().ip(inetAddress).port(port).stream(stream).build());
@Override public Void call() throws Exception { try (SocketChannel channel = SocketChannel.open(new InetSocketAddress(server, port))) { channel.configureBlocking(false); ConnectionInfo connection = new ConnectionInfo(ctx, SYNC, new NetworkAddress.Builder().ip(server).port(port).stream(1).build(), new HashMap<InventoryVector, Long>(), timeoutInSeconds); while (channel.isConnected() && !connection.isSyncFinished()) { write(channel, connection); read(channel, connection); Thread.sleep(10); } LOG.info("Synchronization finished"); } return null; } });
public static Connection sync(InternalContext ctx, InetAddress address, int port, MessageListener listener, long timeoutInSeconds) throws IOException { return new Connection(ctx, SYNC, new Socket(address, port), new HashMap<InventoryVector, Long>(), new NetworkAddress.Builder().ip(address).port(port).stream(1).build(), timeoutInSeconds); }
public Connection(InternalContext context, Mode mode, Socket socket, Map<InventoryVector, Long> requestedObjectsMap) throws IOException { this(context, mode, socket, requestedObjectsMap, new NetworkAddress.Builder().ip(socket.getInetAddress()).port(socket.getPort()).stream(1).build(), 0); }