Refine search
maybeIP = maybeIP.substring(0, i); addresses.add(SocketUtils.socketAddress(maybeIP, port)); } else if (line.startsWith(DOMAIN_ROW_LABEL)) { int i = indexOfNonWhiteSpace(line, DOMAIN_ROW_LABEL.length()); logger.info("row type {} not supported. ignoring line: {}", SORTLIST_ROW_LABEL, line);
public IpSubnetFilterRule(String ipAddress, int cidrPrefix, IpFilterRuleType ruleType) { try { filterRule = selectFilterRule(SocketUtils.addressByName(ipAddress), cidrPrefix, ruleType); } catch (UnknownHostException e) { throw new IllegalArgumentException("ipAddress", e); } }
@Override protected boolean doConnect(final SocketAddress remoteAddress, final SocketAddress localAddress) throws Exception { doBind(localAddress != null? localAddress : new InetSocketAddress(0)); boolean success = false; try { final boolean connected = SocketUtils.connect(javaChannel(), remoteAddress); if (!connected) { selectionKey().interestOps( selectionKey().interestOps() | OP_CONNECT); } success = true; return connected; } finally { if (!success) { doClose(); } } }
NetworkInterface iface = interfaces.nextElement(); Enumeration<InetAddress> addrs = SocketUtils.addressesFromNetworkInterface(iface); if (addrs.hasMoreElements()) { InetAddress a = addrs.nextElement(); logger.warn("Failed to retrieve the list of available network interfaces", e); macAddr = SocketUtils.hardwareAddressFromNetworkInterface(iface); } catch (SocketException e) { logger.debug("Failed to get the hardware address of a network interface: {}", iface, e); continue;
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { if (localAddress != null) { SocketUtils.bind(socket, localAddress); } boolean success = false; try { SocketUtils.connect(socket, remoteAddress, config().getConnectTimeoutMillis()); activate(socket.getInputStream(), socket.getOutputStream()); success = true; } catch (SocketTimeoutException e) { ConnectTimeoutException cause = new ConnectTimeoutException("connection timed out: " + remoteAddress); cause.setStackTrace(e.getStackTrace()); throw cause; } finally { if (!success) { doClose(); } } }
@Override protected int doReadMessages(List<Object> buf) throws Exception { SocketChannel ch = SocketUtils.accept(javaChannel()); try { if (ch != null) { buf.add(new NioSocketChannel(this, ch)); return 1; } } catch (Throwable t) { logger.warn("Failed to create a new channel from an accepted socket.", t); try { ch.close(); } catch (Throwable t2) { logger.warn("Failed to close a socket.", t2); } } return 0; }
logger.debug( "Skipping a nameserver URI as host portion could not be extracted: {}", server); defaultNameServers.add(SocketUtils.socketAddress(uri.getHost(), port == -1 ? defaultPort : port)); } catch (URISyntaxException e) { logger.debug("Skipping a malformed nameserver URI: {}", server, e);
/** * @see #localAddress(SocketAddress) */ public B localAddress(String inetHost, int inetPort) { return localAddress(SocketUtils.socketAddress(inetHost, inetPort)); }
@Override protected SocketAddress localAddress0() { return SocketUtils.localSocketAddress(socket); }
@Override protected void doBind(SocketAddress localAddress) throws Exception { SocketUtils.bind(socket, localAddress); }
@Override public InetAddress getInterface() { NetworkInterface inf = getNetworkInterface(); if (inf != null) { Enumeration<InetAddress> addresses = SocketUtils.addressesFromNetworkInterface(inf); if (addresses.hasMoreElements()) { return addresses.nextElement(); } } return null; }
@Override protected void doResolveAll(String inetHost, Promise<List<InetAddress>> promise) throws Exception { try { promise.setSuccess(Arrays.asList(SocketUtils.allAddressesByName(inetHost))); } catch (UnknownHostException e) { promise.setFailure(e); } } }
@Override protected int doReadMessages(List<Object> buf) throws Exception { final SocketChannelUDT channelUDT = (SocketChannelUDT) SocketUtils.accept(javaChannel()); if (channelUDT == null) { return 0; } else { buf.add(newConnectorChannel(channelUDT)); return 1; } }
NetworkInterface iface = interfaces.nextElement(); Enumeration<InetAddress> addrs = SocketUtils.addressesFromNetworkInterface(iface); if (addrs.hasMoreElements()) { InetAddress a = addrs.nextElement(); logger.warn("Failed to retrieve the list of available network interfaces", e); macAddr = SocketUtils.hardwareAddressFromNetworkInterface(iface); } catch (SocketException e) { logger.debug("Failed to get the hardware address of a network interface: {}", iface, e); continue;
@Override protected int doReadMessages(List<Object> buf) throws Exception { SocketChannel ch = SocketUtils.accept(javaChannel()); try { if (ch != null) { buf.add(new NioSocketChannel(this, ch)); return 1; } } catch (Throwable t) { logger.warn("Failed to create a new channel from an accepted socket.", t); try { ch.close(); } catch (Throwable t2) { logger.warn("Failed to close a socket.", t2); } } return 0; }
/** * Create a new {@link Channel} and bind it. */ public ChannelFuture bind(String inetHost, int inetPort) { return bind(SocketUtils.socketAddress(inetHost, inetPort)); }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { if (localAddress != null) { SocketUtils.bind(socket, localAddress); } boolean success = false; try { SocketUtils.connect(socket, remoteAddress, config().getConnectTimeoutMillis()); activate(socket.getInputStream(), socket.getOutputStream()); success = true; } catch (SocketTimeoutException e) { ConnectTimeoutException cause = new ConnectTimeoutException("connection timed out: " + remoteAddress); cause.setStackTrace(e.getStackTrace()); throw cause; } finally { if (!success) { doClose(); } } }
@Override protected SocketAddress localAddress0() { return SocketUtils.localSocketAddress(socket); }
@Override protected void doBind(SocketAddress localAddress) throws Exception { SocketUtils.bind(socket, localAddress); }
@Override public InetAddress getInterface() { NetworkInterface inf = getNetworkInterface(); if (inf != null) { Enumeration<InetAddress> addresses = SocketUtils.addressesFromNetworkInterface(inf); if (addresses.hasMoreElements()) { return addresses.nextElement(); } } return null; }