@JRubyMethod(name = "getpeername") public IRubyObject getpeername(ThreadContext context) { Ruby runtime = context.runtime; InetSocketAddress sock = getInetRemoteSocket(); if (sock != null) return Sockaddr.pack_sockaddr_in(context, sock); UnixSocketAddress unix = getUnixRemoteSocket(); return Sockaddr.pack_sockaddr_un(context, unix.path()); }
@JRubyMethod(name = "getpeername") public IRubyObject getpeername(ThreadContext context) { Ruby runtime = context.runtime; InetSocketAddress sock = getInetRemoteSocket(); if (sock != null) return Sockaddr.pack_sockaddr_in(context, sock); UnixSocketAddress unix = getUnixRemoteSocket(); return Sockaddr.pack_sockaddr_un(context, unix.path()); }
@JRubyMethod public IRubyObject remote_address(ThreadContext context) { Ruby runtime = context.runtime; InetSocketAddress address = getInetRemoteSocket(); if (address != null) { SocketType socketType = SocketType.forChannel(getChannel()); return new Addrinfo(runtime, runtime.getClass("Addrinfo"), address, socketType.getSocketType(), socketType); } UnixSocketAddress unix = getUnixRemoteSocket(); if (unix != null) { return Addrinfo.unix(context, runtime.getClass("Addrinfo"), runtime.newString(unix.path())); } throw runtime.newErrnoENOTCONNError(); }
@JRubyMethod public IRubyObject remote_address(ThreadContext context) { Ruby runtime = context.runtime; InetSocketAddress address = getInetRemoteSocket(); if (address != null) { SocketType socketType = SocketType.forChannel(getChannel()); return new Addrinfo(runtime, runtime.getClass("Addrinfo"), address, socketType.getSocketType(), socketType); } UnixSocketAddress unix = getUnixRemoteSocket(); if (unix != null) { return Addrinfo.unix(context, runtime.getClass("Addrinfo"), runtime.newString(unix.path())); } throw runtime.newErrnoENOTCONNError(); }