public final String toString() { return description(); } public static ProtocolFamily valueOf(long value) {
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; }
@JRubyMethod public IRubyObject pfamily(ThreadContext context) { return context.runtime.newFixnum(pfamily.intValue()); }
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 public IRubyObject family(ThreadContext context) { return context.runtime.newFixnum(family.longValue()); }
@JRubyMethod(name = {"socketpair", "pair"}, meta = true) public static IRubyObject socketpair(ThreadContext context, IRubyObject recv, IRubyObject domain, IRubyObject type, IRubyObject protocol) { ProtocolFamily pf = SocketUtils.protocolFamilyFromArg(protocol); if (pf == null ) pf = ProtocolFamily.PF_UNIX; if (pf != ProtocolFamily.PF_UNIX && pf.ordinal() != 0) { throw context.runtime.newErrnoEOPNOTSUPPError("Socket.socketpair only supports streaming UNIX sockets"); } return socketpair(context, recv, domain, type); }
@JRubyMethod public IRubyObject afamily(ThreadContext context) { return context.runtime.newFixnum(pfamily.intValue()); }
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 public IRubyObject family(ThreadContext context) { return context.runtime.newFixnum(family.longValue()); }
@JRubyMethod(name = {"socketpair", "pair"}, meta = true) public static IRubyObject socketpair(ThreadContext context, IRubyObject recv, IRubyObject domain, IRubyObject type, IRubyObject protocol) { ProtocolFamily pf = SocketUtils.protocolFamilyFromArg(protocol); if (pf == null ) pf = ProtocolFamily.PF_UNIX; if (pf != ProtocolFamily.PF_UNIX && pf.ordinal() != 0) { throw context.runtime.newErrnoEOPNOTSUPPError("Socket.socketpair only supports streaming UNIX sockets"); } return socketpair(context, recv, domain, type); }
/** * Sets the protocol family of this unix socket address. * * @param family The protocol family, usually {@link ProtocolFamily#PF_UNIX} */ final void setFamily(ProtocolFamily family) { getFamilyField().set(family.intValue()); }
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; }
public final String toString() { return description(); } public static ProtocolFamily valueOf(long value) {
@JRubyMethod public IRubyObject family(ThreadContext context) { return context.runtime.newFixnum(family.longValue()); }
@JRubyMethod public IRubyObject pfamily(ThreadContext context) { return context.runtime.newFixnum(pfamily.intValue()); }
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)); }
public final String toString() { return description(); } public static ProtocolFamily valueOf(long value) {
@JRubyMethod public IRubyObject family(ThreadContext context) { return context.runtime.newFixnum(family.longValue()); }
@JRubyMethod public IRubyObject afamily(ThreadContext context) { return context.runtime.newFixnum(pfamily.intValue()); }
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)); }