protected void doBind(ThreadContext context, Channel channel, InetSocketAddress iaddr) { Ruby runtime = context.runtime; try { if (channel instanceof SocketChannel) { Socket socket = ((SocketChannel)channel).socket(); socket.bind(iaddr); } else if (channel instanceof UnixSocketChannel) { // do nothing } else if (channel instanceof DatagramChannel) { DatagramSocket socket = ((DatagramChannel)channel).socket(); socket.bind(iaddr); } else { throw runtime.newErrnoENOPROTOOPTError(); } } catch(UnknownHostException e) { throw SocketUtils.sockerr(runtime, "bind(2): unknown host"); } catch(SocketException e) { handleSocketException(runtime, "bind", e); } catch(IOException e) { throw SocketUtils.sockerr(runtime, "bind(2): name or service not known"); } catch (IllegalArgumentException iae) { throw SocketUtils.sockerr(runtime, iae.getMessage()); } }
protected void doBind(ThreadContext context, Channel channel, InetSocketAddress iaddr) { Ruby runtime = context.runtime; try { if (channel instanceof SocketChannel) { Socket socket = ((SocketChannel)channel).socket(); socket.bind(iaddr); } else if (channel instanceof UnixSocketChannel) { // do nothing } else if (channel instanceof DatagramChannel) { DatagramSocket socket = ((DatagramChannel)channel).socket(); socket.bind(iaddr); } else { throw runtime.newErrnoENOPROTOOPTError(); } } catch(UnknownHostException e) { throw SocketUtils.sockerr(runtime, "bind(2): unknown host"); } catch(SocketException e) { handleSocketException(runtime, "bind", e); } catch(IOException e) { throw SocketUtils.sockerr(runtime, "bind(2): name or service not known"); } catch (IllegalArgumentException iae) { throw SocketUtils.sockerr(runtime, iae.getMessage()); } }
handleSocketException(runtime, e, "bind(2)", iaddr); // throws
handleSocketException(runtime, e, "bind(2)", iaddr); // throws
handleSocketException(runtime, e, "connect(2)", addr);
handleSocketException(runtime, "connect", e);
handleSocketException(runtime, "connect", e);
handleSocketException(runtime, e, "connect(2)", addr);