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; }
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; }
@JRubyMethod(visibility = Visibility.PRIVATE) public IRubyObject initialize(ThreadContext context) { Ruby runtime = context.runtime; try { DatagramChannel channel = DatagramChannel.open(); initSocket(runtime, new ChannelDescriptor(channel, newModeFlags(runtime, ModeFlags.RDWR))); } catch (ConnectException e) { throw runtime.newErrnoECONNREFUSEDError(); } catch (UnknownHostException e) { throw SocketUtils.sockerr(runtime, "initialize: name or service not known"); } catch (IOException e) { throw SocketUtils.sockerr(runtime, "initialize: name or service not known"); } return this; }
@JRubyMethod(visibility = Visibility.PRIVATE) public IRubyObject initialize(ThreadContext context) { Ruby runtime = context.runtime; try { DatagramChannel channel = DatagramChannel.open(); initSocket(runtime, new ChannelDescriptor(channel, newModeFlags(runtime, ModeFlags.RDWR))); } catch (ConnectException e) { throw runtime.newErrnoECONNREFUSEDError(); } catch (UnknownHostException e) { throw SocketUtils.sockerr(runtime, "initialize: name or service not known"); } catch (IOException e) { throw SocketUtils.sockerr(runtime, "initialize: name or service not known"); } return this; }