private void setType(Ruby runtime, IRubyObject type) { Sock sockType = SocketUtils.sockFromArg(type); if (sockType == null) { throw SocketUtils.sockerr(runtime, "unknown socket type " + type); } soType = sockType; }
private void setType(Ruby runtime, IRubyObject type) { Sock sockType = SocketUtils.sockFromArg(type); if (sockType == null) { throw SocketUtils.sockerr(runtime, "unknown socket type " + type); } soType = sockType; }
private void initType(Ruby runtime, IRubyObject type) { Sock sockType = SocketUtils.sockFromArg(type); if (sockType == null) { throw SocketUtils.sockerr(runtime, "unknown socket type " + type); } soType = sockType; }
private void initType(Ruby runtime, IRubyObject type) { Sock sockType = SocketUtils.sockFromArg(type); if (sockType == null) { throw SocketUtils.sockerr(runtime, "unknown socket type " + type); } soType = sockType; }
private void setSockAndProtocol(IRubyObject sock) { setSockAndProtocol(sock == null ? null : SocketUtils.sockFromArg(sock)); }
private void setSockAndProtocol(IRubyObject sock) { setSockAndProtocol(sock == null ? null : SocketUtils.sockFromArg(sock)); }
@JRubyMethod(meta = true) public static IRubyObject unix(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject type) { Addrinfo addrinfo = new Addrinfo(context.runtime, (RubyClass) recv); addrinfo.socketAddress = new UnixSocketAddress(new File(path.convertToString().toString())); addrinfo.sock = SocketUtils.sockFromArg(type); addrinfo.socketType = SocketType.UNIX; addrinfo.pfamily = PF_UNIX; addrinfo.protocol = Protocol.getProtocolByName("ip"); return addrinfo; }
@JRubyMethod(meta = true) public static IRubyObject unix(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject type) { Addrinfo addrinfo = new Addrinfo(context.runtime, (RubyClass) recv); addrinfo.socketAddress = new UnixSocketAddress(new File(path.convertToString().toString())); addrinfo.sock = SocketUtils.sockFromArg(type); addrinfo.socketType = SocketType.UNIX; addrinfo.pfamily = PF_UNIX; addrinfo.protocol = Protocol.getProtocolByName("ip"); return addrinfo; }
this.sock = Sock.SOCK_STREAM; } else { this.sock = SocketUtils.sockFromArg(sock);
this.sock = Sock.SOCK_STREAM; } else { this.sock = SocketUtils.sockFromArg(sock);
Sock sock = socktype.isNil() ? SOCK_STREAM : sockFromArg(socktype);
Sock sock = socktype.isNil() ? SOCK_STREAM : sockFromArg(socktype);
@JRubyMethod(name = {"socketpair", "pair"}, meta = true) public static IRubyObject socketpair(ThreadContext context, IRubyObject recv, IRubyObject domain, IRubyObject type) { AddressFamily af = SocketUtils.addressFamilyFromArg(domain); if (af == null) af = AddressFamily.AF_UNIX; Sock s = SocketUtils.sockFromArg(type); if (s == null) s = Sock.SOCK_STREAM; if (af != AddressFamily.AF_UNIX || s != Sock.SOCK_STREAM) { throw context.runtime.newErrnoEOPNOTSUPPError("Socket.socketpair only supports streaming UNIX sockets"); } final Ruby runtime = context.runtime; // TODO: type and protocol UnixSocketChannel[] sp; try { sp = UnixSocketChannel.pair(); final RubyClass socketClass = runtime.getClass("Socket"); RubySocket sock0 = new RubySocket(runtime, socketClass); ChannelFD fd0 = newChannelFD(runtime, sp[0]); sock0.initFieldsFromDescriptor(runtime, fd0); sock0.initSocket(fd0); RubySocket sock1 = new RubySocket(runtime, socketClass); ChannelFD fd1 = newChannelFD(runtime, sp[1]); sock1.initFieldsFromDescriptor(runtime, fd1); sock1.initSocket(fd1); return runtime.newArray(sock0, sock1); } catch (IOException ioe) { throw runtime.newIOErrorFromException(ioe); } }
@JRubyMethod(name = {"socketpair", "pair"}, meta = true) public static IRubyObject socketpair(ThreadContext context, IRubyObject recv, IRubyObject domain, IRubyObject type) { AddressFamily af = SocketUtils.addressFamilyFromArg(domain); if (af == null) af = AddressFamily.AF_UNIX; Sock s = SocketUtils.sockFromArg(type); if (s == null) s = Sock.SOCK_STREAM; if (af != AddressFamily.AF_UNIX || s != Sock.SOCK_STREAM) { throw context.runtime.newErrnoEOPNOTSUPPError("Socket.socketpair only supports streaming UNIX sockets"); } final Ruby runtime = context.runtime; // TODO: type and protocol UnixSocketChannel[] sp; try { sp = UnixSocketChannel.pair(); final RubyClass socketClass = runtime.getClass("Socket"); RubySocket sock0 = new RubySocket(runtime, socketClass); ChannelFD fd0 = newChannelFD(runtime, sp[0]); sock0.initFieldsFromDescriptor(runtime, fd0); sock0.initSocket(fd0); RubySocket sock1 = new RubySocket(runtime, socketClass); ChannelFD fd1 = newChannelFD(runtime, sp[1]); sock1.initFieldsFromDescriptor(runtime, fd1); sock1.initSocket(fd1); return runtime.newArray(sock0, sock1); } catch (IOException ioe) { throw runtime.newIOErrorFromException(ioe); } }