@Override public RubyBoolean closed_p(ThreadContext context) { if (getOpenFile() == null) return context.fals; return super.closed_p(context); }
/** * Get the count of available addresses. * Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false. * @return the count of addresses, may be zero. */ public int getAddressCount() { int count = broadcast() - network() + (isInclusiveHostCount() ? 1 : -1); return count < 0 ? 0 : count; }
private static ReceiveTuple doReceiveTuple(RubyBasicSocket socket, final Ruby runtime, final boolean non_block, int length) throws IOException { ReceiveTuple tuple = new ReceiveTuple(); final IRubyObject result; if (socket.multicastStateManager == null) { result = doReceive(socket, runtime, non_block, length, tuple); } else { result = doReceiveMulticast(socket, runtime, non_block, length, tuple); } return result == null ? null : tuple; // need to return null for non_block (if op would block) }
protected InetSocketAddress getRemoteSocket() throws BadDescriptorException { Channel channel = getOpenChannel(); return (InetSocketAddress)SocketType.forChannel(channel).getRemoteSocketAddress(channel); }
protected SocketAddress getSocketAddress() { Channel channel = getChannel(); return SocketType.forChannel(channel).getLocalSocketAddress(channel); }
protected SocketAddress getSocketAddress() { Channel channel = getOpenChannel(); return SocketType.forChannel(channel).getLocalSocketAddress(channel); }
private void setNetmask(InterfaceAddress it) throws Exception { if ( ( isLoopback || ( it.getNetworkPrefixLength() != 0 ) ) && ( address instanceof Inet4Address) ) { String subnet = ipAddress() + "/" + it.getNetworkPrefixLength(); if ( isLoopback ) { subnet = ipAddress() + "/8"; // because getNetworkPrefixLength() incorrectly returns 0 for IPv4 loopback } SubnetUtils utils = new SubnetUtils(subnet); netmask = utils.getInfo().getNetmask(); } else if ( (it.getNetworkPrefixLength() != 0 ) && ( address instanceof Inet6Address) ) { netmask = SocketUtilsIPV6.getIPV6NetMask(ipAddress() + "/" + it.getNetworkPrefixLength()); } }
public static String getIPV6NetMask(String ip) { IPv6Network strangeNetwork = new IPv6Network().fromString(ip); return strangeNetwork.getNetmask().asAddress().toString(); }
private ReceiveTuple doReceiveTuple(Ruby runtime, int length) throws IOException { ReceiveTuple tuple = new ReceiveTuple(); if (this.multicastStateManager == null) { doReceive(runtime, length, tuple); } else { doReceiveMulticast(runtime, length, tuple); } return tuple; }
private void initFromArgs(Ruby runtime, IRubyObject domain, IRubyObject type) { setDomain(runtime, domain); setType(runtime, type); ChannelFD fd = initChannelFD(runtime); initSocket(fd); }
/** * Overrides IPSocket#recvfrom */ @Override public IRubyObject recvfrom(ThreadContext context, IRubyObject length) { return recvfrom(this, context, length); }
private void setNetmask(InterfaceAddress it) throws Exception { if ( ( isLoopback || ( it.getNetworkPrefixLength() != 0 ) ) && ( address instanceof Inet4Address) ) { String subnet = ipAddress() + "/" + it.getNetworkPrefixLength(); if ( isLoopback ) { subnet = ipAddress() + "/8"; // because getNetworkPrefixLength() incorrectly returns 0 for IPv4 loopback } SubnetUtils utils = new SubnetUtils(subnet); netmask = utils.getInfo().getNetmask(); } else if ( (it.getNetworkPrefixLength() != 0 ) && ( address instanceof Inet6Address) ) { netmask = SocketUtilsIPV6.getIPV6NetMask(ipAddress() + "/" + it.getNetworkPrefixLength()); } }
private static ReceiveTuple doReceiveTuple(RubyBasicSocket socket, final Ruby runtime, final boolean non_block, int length) throws IOException { ReceiveTuple tuple = new ReceiveTuple(); final IRubyObject result; if (socket.multicastStateManager == null) { result = doReceive(socket, runtime, non_block, length, tuple); } else { result = doReceiveMulticast(socket, runtime, non_block, length, tuple); } return result == null ? null : tuple; // need to return null for non_block (if op would block) }
public static String getIPV6NetMask(String ip) { IPv6Network strangeNetwork = new IPv6Network().fromString(ip); return strangeNetwork.getNetmask().asAddress().toString(); }
private ReceiveTuple doReceiveTuple(Ruby runtime, int length) throws IOException { ReceiveTuple tuple = new ReceiveTuple(); if (this.multicastStateManager == null) { doReceive(runtime, length, tuple); } else { doReceiveMulticast(runtime, length, tuple); } return tuple; }
/** * Get the count of available addresses. * Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false. * @return the count of addresses, may be zero. */ public int getAddressCount() { int count = broadcast() - network() + (isInclusiveHostCount() ? 1 : -1); return count < 0 ? 0 : count; }
@Override public RubyBoolean closed_p(ThreadContext context) { if (getOpenFile() == null) return context.fals; return super.closed_p(context); }
private int high() { return (isInclusiveHostCount() ? broadcast() : broadcast() - network() > 1 ? broadcast() -1 : 0); }
private int high() { return (isInclusiveHostCount() ? broadcast() : broadcast() - network() > 1 ? broadcast() -1 : 0); }
private int low() { return (isInclusiveHostCount() ? network() : broadcast() - network() > 1 ? network() + 1 : 0); }