protected void initFromServer(Ruby runtime, RubyServerSocket serverSocket, SocketChannel socketChannel) { soDomain = serverSocket.soDomain; soType = serverSocket.soType; soProtocol = serverSocket.soProtocol; initSocket(runtime, newChannelDescriptor(runtime, socketChannel)); }
protected void initFromServer(Ruby runtime, RubySocket serverSocket, SocketChannel socketChannel) { soDomain = serverSocket.soDomain; soType = serverSocket.soType; soProtocol = serverSocket.soProtocol; initSocket(newChannelFD(runtime, socketChannel)); }
protected void initFromServer(Ruby runtime, RubyServerSocket serverSocket, SocketChannel socketChannel) { soDomain = serverSocket.soDomain; soType = serverSocket.soType; soProtocol = serverSocket.soProtocol; initSocket(runtime, newChannelDescriptor(runtime, socketChannel)); }
protected void initFromServer(Ruby runtime, RubySocket serverSocket, SocketChannel socketChannel) { soDomain = serverSocket.soDomain; soType = serverSocket.soType; soProtocol = serverSocket.soProtocol; initSocket(newChannelFD(runtime, socketChannel)); }
@JRubyMethod(name = "initialize", compat = CompatVersion.RUBY1_9) public IRubyObject initialize19(ThreadContext context, IRubyObject domain, IRubyObject type) { Ruby runtime = context.runtime; initFieldsFromArgs(runtime, domain, type); ChannelDescriptor descriptor = initChannel(runtime); initSocket(runtime, descriptor); return this; }
private void initFromArgs(Ruby runtime, IRubyObject domain, IRubyObject type) { setDomain(runtime, domain); setType(runtime, type); ChannelFD fd = initChannelFD(runtime); initSocket(fd); }
@JRubyMethod(compat = CompatVersion.RUBY1_8) public IRubyObject initialize(ThreadContext context, IRubyObject domain, IRubyObject type, IRubyObject protocol) { Ruby runtime = context.runtime; initFieldsFromArgs(runtime, domain, type, protocol); ChannelDescriptor descriptor = initChannel(runtime); initSocket(runtime, descriptor); return this; }
@JRubyMethod(compat = CompatVersion.RUBY1_8) public IRubyObject initialize(ThreadContext context, IRubyObject domain, IRubyObject type, IRubyObject protocol) { Ruby runtime = context.runtime; initFieldsFromArgs(runtime, domain, type, protocol); ChannelDescriptor descriptor = initChannel(runtime); initSocket(runtime, descriptor); return this; }
@JRubyMethod(name = "initialize", compat = CompatVersion.RUBY1_9) public IRubyObject initialize19(ThreadContext context, IRubyObject domain, IRubyObject type, IRubyObject protocol) { Ruby runtime = context.runtime; initFieldsFromArgs(runtime, domain, type, protocol); ChannelDescriptor descriptor = initChannel(runtime); initSocket(runtime, descriptor); return this; }
@JRubyMethod(name = "initialize", compat = CompatVersion.RUBY1_9) public IRubyObject initialize19(ThreadContext context, IRubyObject domain, IRubyObject type, IRubyObject protocol) { Ruby runtime = context.runtime; initFieldsFromArgs(runtime, domain, type, protocol); ChannelDescriptor descriptor = initChannel(runtime); initSocket(runtime, descriptor); return this; }
private void initFromArgs(Ruby runtime, IRubyObject domain, IRubyObject type) { setDomain(runtime, domain); setType(runtime, type); ChannelFD fd = initChannelFD(runtime); initSocket(fd); }
@JRubyMethod(name = "initialize", compat = CompatVersion.RUBY1_9) public IRubyObject initialize19(ThreadContext context, IRubyObject domain, IRubyObject type) { Ruby runtime = context.runtime; initFieldsFromArgs(runtime, domain, type); ChannelDescriptor descriptor = initChannel(runtime); initSocket(runtime, descriptor); return this; }
@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(meta = true) public static IRubyObject for_fd(ThreadContext context, IRubyObject socketClass, IRubyObject fd) { Ruby runtime = context.runtime; if (fd instanceof RubyFixnum) { int intFD = (int)((RubyFixnum)fd).getLongValue(); ChannelDescriptor descriptor = ChannelDescriptor.getDescriptorByFileno(intFD); if (descriptor == null) { throw runtime.newErrnoEBADFError(); } RubySocket socket = (RubySocket)((RubyClass)socketClass).allocate(); socket.initFieldsFromDescriptor(runtime, descriptor); socket.initSocket(runtime, descriptor); return socket; } else { throw runtime.newTypeError(fd, context.runtime.getFixnum()); } }
@JRubyMethod(meta = true) public static IRubyObject for_fd(ThreadContext context, IRubyObject socketClass, IRubyObject fd) { Ruby runtime = context.runtime; if (fd instanceof RubyFixnum) { int intFD = (int)((RubyFixnum)fd).getLongValue(); ChannelDescriptor descriptor = ChannelDescriptor.getDescriptorByFileno(intFD); if (descriptor == null) { throw runtime.newErrnoEBADFError(); } RubySocket socket = (RubySocket)((RubyClass)socketClass).allocate(); socket.initFieldsFromDescriptor(runtime, descriptor); socket.initSocket(runtime, descriptor); return socket; } else { throw runtime.newTypeError(fd, context.runtime.getFixnum()); } }
@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(meta = true) public static IRubyObject for_fd(ThreadContext context, IRubyObject socketClass, IRubyObject _fd) { Ruby runtime = context.runtime; if (_fd instanceof RubyFixnum) { int intFD = (int)((RubyFixnum)_fd).getLongValue(); ChannelFD fd = runtime.getFilenoUtil().getWrapperFromFileno(intFD); if (fd == null) { throw runtime.newErrnoEBADFError(); } RubySocket socket = (RubySocket)((RubyClass)socketClass).allocate(); socket.initFieldsFromDescriptor(runtime, fd); socket.initSocket(fd); return socket; } else { throw runtime.newTypeError(_fd, context.runtime.getFixnum()); } }
@JRubyMethod(meta = true) public static IRubyObject for_fd(ThreadContext context, IRubyObject socketClass, IRubyObject _fd) { Ruby runtime = context.runtime; if (_fd instanceof RubyFixnum) { int intFD = (int)((RubyFixnum)_fd).getLongValue(); ChannelFD fd = runtime.getFilenoUtil().getWrapperFromFileno(intFD); if (fd == null) { throw runtime.newErrnoEBADFError(); } RubySocket socket = (RubySocket)((RubyClass)socketClass).allocate(); socket.initFieldsFromDescriptor(runtime, fd); socket.initSocket(fd); return socket; } else { throw runtime.newTypeError(_fd, context.runtime.getFixnum()); } }