protected UnixSocketAddress getUnixRemoteSocket() { SocketAddress socketAddress = getRemoteSocket(); if (socketAddress instanceof UnixSocketAddress) return (UnixSocketAddress) socketAddress; return null; }
protected UnixSocketAddress getUnixRemoteSocket() { SocketAddress socketAddress = getRemoteSocket(); if (socketAddress instanceof UnixSocketAddress) return (UnixSocketAddress) socketAddress; return null; }
protected InetSocketAddress getInetRemoteSocket() { SocketAddress socketAddress = getRemoteSocket(); if (socketAddress instanceof InetSocketAddress) return (InetSocketAddress) socketAddress; return null; }
protected InetSocketAddress getInetRemoteSocket() { SocketAddress socketAddress = getRemoteSocket(); if (socketAddress instanceof InetSocketAddress) return (InetSocketAddress) socketAddress; return null; }
@JRubyMethod(name = "getpeername") public IRubyObject getpeername(ThreadContext context) { Ruby runtime = context.runtime; try { SocketAddress sock = getRemoteSocket(); if(null == sock) { throw runtime.newIOError("Not Supported"); } return runtime.newString(sock.toString()); } catch (BadDescriptorException e) { throw runtime.newErrnoEBADFError(); } }
@JRubyMethod(name = "getpeername") public IRubyObject getpeername(ThreadContext context) { Ruby runtime = context.runtime; try { SocketAddress sock = getRemoteSocket(); if(null == sock) { throw runtime.newIOError("Not Supported"); } return runtime.newString(sock.toString()); } catch (BadDescriptorException e) { throw runtime.newErrnoEBADFError(); } }
@JRubyMethod(compat = CompatVersion.RUBY1_9) public IRubyObject remote_address(ThreadContext context) { try { InetSocketAddress address = getRemoteSocket(); if (address == null) { return context.nil; } else { return new Addrinfo(context.runtime, context.runtime.getClass("Addrinfo"), address.getAddress(), address.getPort(), SocketType.forChannel(getChannel())); } } catch (BadDescriptorException bde) { throw context.runtime.newErrnoEBADFError("address unavailable"); } }
@JRubyMethod(compat = CompatVersion.RUBY1_9) public IRubyObject remote_address(ThreadContext context) { try { InetSocketAddress address = getRemoteSocket(); if (address == null) { return context.nil; } else { return new Addrinfo(context.runtime, context.runtime.getClass("Addrinfo"), address.getAddress(), address.getPort(), SocketType.forChannel(getChannel())); } } catch (BadDescriptorException bde) { throw context.runtime.newErrnoEBADFError("address unavailable"); } }