public static void writeSockaddrHeader(AddressFamily family, DataOutputStream ds) throws IOException { int value = family.intValue(); int high = (value & 0xff00) >> 8; int low = value & 0xff; ds.write((byte)high); ds.write((byte)low); }
public static void writeSockaddrHeader(AddressFamily family, DataOutputStream ds) throws IOException { int value = family.intValue(); int high = (value & 0xff00) >> 8; int low = value & 0xff; ds.write((byte)high); ds.write((byte)low); }
public static void writeSockaddrHeader(AddressFamily family, DataOutputStream ds) throws IOException { int value = family.intValue(); int high = (value & 0xff00) >> 8; int low = value & 0xff; ds.write((byte)high); ds.write((byte)low); }
public static void writeSockaddrHeader(AddressFamily family, DataOutputStream ds) throws IOException { int value = family.intValue(); int high = (value & 0xff00) >> 8; int low = value & 0xff; ds.write((byte)high); ds.write((byte)low); }
public static IRubyObject pack_sockaddr_un(ThreadContext context, String unixpath) { final Ruby runtime = context.runtime; ByteBuffer buf = ByteBuffer.allocate(SOCKADDR_UN_SIZE); byte[] path = unixpath.getBytes(); if (path.length > SOCKADDR_UN_PATH) { String errorMsg = "too long unix socket path (%d bytes given but %d bytes max)"; String formattedErrorMsg = String.format(errorMsg, path.length, SOCKADDR_UN_PATH); throw runtime.newArgumentError(formattedErrorMsg); } int afamily = AddressFamily.AF_UNIX.intValue(); int high = (afamily & 0xff00) >> 8; int low = afamily & 0xff; buf.put((byte)high); buf.put((byte)low); buf.put(path); return RubyString.newString(runtime, buf.array()); }
public static IRubyObject pack_sockaddr_un(ThreadContext context, String unixpath) { final Ruby runtime = context.runtime; ByteBuffer buf = ByteBuffer.allocate(SOCKADDR_UN_SIZE); byte[] path = unixpath.getBytes(); if (path.length > SOCKADDR_UN_PATH) { String errorMsg = "too long unix socket path (%d bytes given but %d bytes max)"; String formattedErrorMsg = String.format(errorMsg, path.length, SOCKADDR_UN_PATH); throw runtime.newArgumentError(formattedErrorMsg); } int afamily = AddressFamily.AF_UNIX.intValue(); int high = (afamily & 0xff00) >> 8; int low = afamily & 0xff; buf.put((byte)high); buf.put((byte)low); buf.put(path); return RubyString.newString(runtime, buf.array()); }
@JRubyMethod(notImplemented = true) public IRubyObject pfamily(ThreadContext context) { return context.runtime.newFixnum(afamily.intValue()); }
@JRubyMethod(notImplemented = true) public IRubyObject pfamily(ThreadContext context) { return context.runtime.newFixnum(afamily.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); }
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); }
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); }
@JRubyMethod public IRubyObject afamily(ThreadContext context) { return context.runtime.newFixnum(getAddressFamily().intValue()); }
@JRubyMethod public IRubyObject afamily(ThreadContext context) { return context.runtime.newFixnum(getAddressFamily().intValue()); }
public static IRubyObject pack_sockaddr_un(ThreadContext context, IRubyObject filename) { ByteList str = filename.convertToString().getByteList(); AddressFamily af = AddressFamily.AF_UNIX; int high = (af.intValue() & 0xff00) >> 8; int low = af.intValue() & 0xff; ByteList bl = new ByteList(); bl.append((byte)high); bl.append((byte)low); bl.append(str); for(int i=str.length();i<104;i++) { bl.append((byte)0); } return context.runtime.newString(bl); }
public static IRubyObject pack_sockaddr_un(ThreadContext context, IRubyObject filename) { ByteList str = filename.convertToString().getByteList(); AddressFamily af = AddressFamily.AF_UNIX; int high = (af.intValue() & 0xff00) >> 8; int low = af.intValue() & 0xff; ByteList bl = new ByteList(); bl.append((byte)high); bl.append((byte)low); bl.append(str); for(int i=str.length();i<104;i++) { bl.append((byte)0); } return context.runtime.newString(bl); }
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); } }