org.jruby.Ruby.newErrnoEOPNOTSUPPError()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.jruby.Ruby.newErrnoEOPNOTSUPPError方法的一些代码示例,展示了Ruby.newErrnoEOPNOTSUPPError的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.newErrnoEOPNOTSUPPError方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:newErrnoEOPNOTSUPPError

Ruby.newErrnoEOPNOTSUPPError介绍

暂无

代码示例

代码示例来源:origin: org.jruby/jruby-complete

@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);
}

代码示例来源:origin: org.jruby/jruby-core

@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);
}

代码示例来源:origin: org.jruby/jruby-complete

@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);
  }
}

代码示例来源:origin: org.jruby/jruby-core

@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);
  }
}

相关文章

微信公众号

最新文章

更多

Ruby类方法