static ProtocolFamily protocolFamilyFromArg(IRubyObject protocol) { ProtocolFamily protocolFamily = null; if(protocol instanceof RubyString || protocol instanceof RubySymbol) { String protocolString = protocol.toString(); protocolFamily = ProtocolFamily.valueOf("PF_" + protocolString); } else { int protocolInt = RubyNumeric.fix2int(protocol); if (protocolInt == 0) return null; protocolFamily = ProtocolFamily.valueOf(protocolInt); } return protocolFamily; }
static ProtocolFamily protocolFamilyFromArg(IRubyObject protocol) { ProtocolFamily protocolFamily = null; if(protocol instanceof RubyString || protocol instanceof RubySymbol) { String protocolString = protocol.toString(); protocolFamily = ProtocolFamily.valueOf("PF_" + protocolString); } else { int protocolInt = RubyNumeric.fix2int(protocol); if (protocolInt == 0) return null; protocolFamily = ProtocolFamily.valueOf(protocolInt); } return protocolFamily; }
private void setDomain(Ruby runtime, IRubyObject domain) { AddressFamily family = SocketUtils.addressFamilyFromArg(domain); if (family == null) { throw SocketUtils.sockerr(runtime, "unknown socket domain " + domain); } soDomain = family; String name = soDomain.name(); if (name.startsWith("pseudo_")) name = name.substring(7); soProtocolFamily = ProtocolFamily.valueOf("PF" + name.substring(2)); }
private void setDomain(Ruby runtime, IRubyObject domain) { AddressFamily family = SocketUtils.addressFamilyFromArg(domain); if (family == null) { throw SocketUtils.sockerr(runtime, "unknown socket domain " + domain); } soDomain = family; String name = soDomain.name(); if (name.startsWith("pseudo_")) name = name.substring(7); soProtocolFamily = ProtocolFamily.valueOf("PF" + name.substring(2)); }
/** * Gets the protocol family of this unix socket address. * * @return The protocol family */ final ProtocolFamily getFamily() { return ProtocolFamily.valueOf(getFamilyField().intValue()); }
public Addrinfo(Ruby runtime, RubyClass cls, InetAddress inetAddress, int port, Sock sock) { super(runtime, cls); this.socketAddress = new InetSocketAddress(inetAddress, port); this.pfamily = ProtocolFamily.valueOf(getAddressFamily().intValue()); this.socketType = SocketType.SOCKET; setSockAndProtocol(sock); }
public Addrinfo(Ruby runtime, RubyClass cls, InetAddress inetAddress, int port, Sock sock) { super(runtime, cls); this.socketAddress = new InetSocketAddress(inetAddress, port); this.pfamily = ProtocolFamily.valueOf(getAddressFamily().intValue()); this.socketType = SocketType.SOCKET; setSockAndProtocol(sock); }
static ProtocolFamily protocolFamilyFromArg(IRubyObject protocol) { IRubyObject maybeString = TypeConverter.checkStringType(protocol.getRuntime(), protocol); if (!maybeString.isNil()) { protocol = maybeString; } try { if (protocol instanceof RubyString || protocol instanceof RubySymbol) { String protocolString = protocol.toString(); if (protocolString.startsWith("PF_")) return ProtocolFamily.valueOf(protocolString); if (protocolString.startsWith("AF_")) return ProtocolFamily.valueOf(AddressFamily.valueOf(protocolString).intValue()); return ProtocolFamily.valueOf("PF_" + protocolString); } int protocolInt = RubyNumeric.fix2int(protocol); return ProtocolFamily.valueOf(protocolInt); } catch (IllegalArgumentException iae) { throw SocketUtils.sockerr(protocol.getRuntime(), "invalid protocol family: " + protocol); } }
static ProtocolFamily protocolFamilyFromArg(IRubyObject protocol) { IRubyObject maybeString = TypeConverter.checkStringType(protocol.getRuntime(), protocol); if (!maybeString.isNil()) { protocol = maybeString; } try { if (protocol instanceof RubyString || protocol instanceof RubySymbol) { String protocolString = protocol.toString(); if (protocolString.startsWith("PF_")) return ProtocolFamily.valueOf(protocolString); if (protocolString.startsWith("AF_")) return ProtocolFamily.valueOf(AddressFamily.valueOf(protocolString).intValue()); return ProtocolFamily.valueOf("PF_" + protocolString); } int protocolInt = RubyNumeric.fix2int(protocol); return ProtocolFamily.valueOf(protocolInt); } catch (IllegalArgumentException iae) { throw SocketUtils.sockerr(protocol.getRuntime(), "invalid protocol family: " + protocol); } }
private void initDomain(Ruby runtime, IRubyObject domain) { AddressFamily family = SocketUtils.addressFamilyFromArg(domain); if (family == null) { throw SocketUtils.sockerr(runtime, "unknown socket domain " + domain); } soDomain = family; soProtocol = ProtocolFamily.valueOf("PF" + soDomain.name().substring(2)); }
private void initDomain(Ruby runtime, IRubyObject domain) { AddressFamily family = SocketUtils.addressFamilyFromArg(domain); if (family == null) { throw SocketUtils.sockerr(runtime, "unknown socket domain " + domain); } soDomain = family; soProtocol = ProtocolFamily.valueOf("PF" + soDomain.name().substring(2)); }
public Addrinfo(Ruby runtime, RubyClass cls, SocketAddress socketAddress, Sock sock, SocketType socketType) { super(runtime, cls); this.socketAddress = socketAddress; this.pfamily = ProtocolFamily.valueOf(getAddressFamily().intValue()); this.socketType = socketType; setSockAndProtocol(sock); }
public Addrinfo(Ruby runtime, RubyClass cls, SocketAddress socketAddress) { super(runtime, cls); this.socketAddress = socketAddress; this.pfamily = ProtocolFamily.valueOf(getAddressFamily().intValue()); setSockAndProtocol(Sock.SOCK_STREAM); }
public Addrinfo(Ruby runtime, RubyClass cls, SocketAddress socketAddress, Sock sock, SocketType socketType) { super(runtime, cls); this.socketAddress = socketAddress; this.pfamily = ProtocolFamily.valueOf(getAddressFamily().intValue()); this.socketType = socketType; setSockAndProtocol(sock); }
public Addrinfo(Ruby runtime, RubyClass cls, SocketAddress socketAddress) { super(runtime, cls); this.socketAddress = socketAddress; this.pfamily = ProtocolFamily.valueOf(getAddressFamily().intValue()); setSockAndProtocol(Sock.SOCK_STREAM); }
static AddressFamily addressFamilyFromArg(IRubyObject domain) { IRubyObject maybeString = TypeConverter.checkStringType(domain.getRuntime(), domain); if (!maybeString.isNil()) { domain = maybeString; } try { if (domain instanceof RubyString || domain instanceof RubySymbol) { String domainString = domain.toString(); if (domainString.startsWith("AF_")) return AddressFamily.valueOf(domainString); if (domainString.startsWith("PF_")) return AddressFamily.valueOf(ProtocolFamily.valueOf(domainString).intValue()); return AddressFamily.valueOf("AF_" + domainString); } int domainInt = RubyNumeric.fix2int(domain); return AddressFamily.valueOf(domainInt); } catch (IllegalArgumentException iae) { throw SocketUtils.sockerr(domain.getRuntime(), "invalid address family: " + domain); } }
static AddressFamily addressFamilyFromArg(IRubyObject domain) { IRubyObject maybeString = TypeConverter.checkStringType(domain.getRuntime(), domain); if (!maybeString.isNil()) { domain = maybeString; } try { if (domain instanceof RubyString || domain instanceof RubySymbol) { String domainString = domain.toString(); if (domainString.startsWith("AF_")) return AddressFamily.valueOf(domainString); if (domainString.startsWith("PF_")) return AddressFamily.valueOf(ProtocolFamily.valueOf(domainString).intValue()); return AddressFamily.valueOf("AF_" + domainString); } int domainInt = RubyNumeric.fix2int(domain); return AddressFamily.valueOf(domainInt); } catch (IllegalArgumentException iae) { throw SocketUtils.sockerr(domain.getRuntime(), "invalid address family: " + domain); } }
@JRubyMethod(required = 4) public IRubyObject initialize(ThreadContext context, IRubyObject[] args) { family = ProtocolFamily.valueOf(args[0].convertToInteger().getLongValue()); level = SocketLevel.valueOf(args[1].convertToInteger().getLongValue()); option = SocketOption.valueOf(args[2].convertToInteger().getLongValue()); data = args[3].convertToString().getByteList(); intData = Pack.unpackInt_i(ByteBuffer.wrap(data.bytes())); return context.nil; }
@JRubyMethod(required = 4) public IRubyObject initialize(ThreadContext context, IRubyObject[] args) { family = ProtocolFamily.valueOf(args[0].convertToInteger().getLongValue()); level = SocketLevel.valueOf(args[1].convertToInteger().getLongValue()); option = SocketOption.valueOf(args[2].convertToInteger().getLongValue()); data = args[3].convertToString().getByteList(); intData = Pack.unpackInt_i(ByteBuffer.wrap(data.bytes())); return context.nil; }