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

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

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

Ruby.newErrnoEAFNOSUPPORTError介绍

暂无

代码示例

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

@JRubyMethod(visibility = Visibility.PRIVATE)
public IRubyObject initialize(ThreadContext context, IRubyObject _family) {
  AddressFamily family = SocketUtils.addressFamilyFromArg(_family);
  if (family == AddressFamily.AF_INET) {
    explicitFamily = Inet4Address.class;
    return initialize(context, StandardProtocolFamily.INET);
  } else if (family == AddressFamily.AF_INET6) {
    explicitFamily = Inet6Address.class;
    return initialize(context, StandardProtocolFamily.INET6);
  }
  throw context.runtime.newErrnoEAFNOSUPPORTError("invalid family for UDPSocket: " + _family);
}

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

@JRubyMethod(visibility = Visibility.PRIVATE)
public IRubyObject initialize(ThreadContext context, IRubyObject _family) {
  AddressFamily family = SocketUtils.addressFamilyFromArg(_family);
  if (family == AddressFamily.AF_INET) {
    explicitFamily = Inet4Address.class;
    return initialize(context, StandardProtocolFamily.INET);
  } else if (family == AddressFamily.AF_INET6) {
    explicitFamily = Inet6Address.class;
    return initialize(context, StandardProtocolFamily.INET6);
  }
  throw context.runtime.newErrnoEAFNOSUPPORTError("invalid family for UDPSocket: " + _family);
}

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

public IRubyObject initialize(ThreadContext context, ProtocolFamily family) {
  Ruby runtime = context.runtime;
  try {
    this.family = family;
    DatagramChannel channel = DatagramChannel.open(family);
    initSocket(newChannelFD(runtime, channel));
  } catch (ConnectException e) {
    throw runtime.newErrnoECONNREFUSEDError();
  } catch (UnknownHostException e) {
    throw SocketUtils.sockerr(runtime, "initialize: name or service not known");
  } catch (UnsupportedOperationException uoe) {
    if (uoe.getMessage().contains("IPv6 not available")) {
      throw runtime.newErrnoEAFNOSUPPORTError("socket(2) - udp");
    }
    throw sockerr(runtime, "UnsupportedOperationException: " + uoe.getLocalizedMessage(), uoe);
  } catch (IOException e) {
    throw sockerr(runtime, "initialize: name or service not known", e);
  }
  return this;
}

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

public IRubyObject initialize(ThreadContext context, ProtocolFamily family) {
  Ruby runtime = context.runtime;
  try {
    this.family = family;
    DatagramChannel channel = DatagramChannel.open(family);
    initSocket(newChannelFD(runtime, channel));
  } catch (ConnectException e) {
    throw runtime.newErrnoECONNREFUSEDError();
  } catch (UnknownHostException e) {
    throw SocketUtils.sockerr(runtime, "initialize: name or service not known");
  } catch (UnsupportedOperationException uoe) {
    if (uoe.getMessage().contains("IPv6 not available")) {
      throw runtime.newErrnoEAFNOSUPPORTError("socket(2) - udp");
    }
    throw sockerr(runtime, "UnsupportedOperationException: " + uoe.getLocalizedMessage(), uoe);
  } catch (IOException e) {
    throw sockerr(runtime, "initialize: name or service not known", e);
  }
  return this;
}

相关文章

微信公众号

最新文章

更多

Ruby类方法