protected IRubyObject getSocknameCommon(ThreadContext context, String caller) { if (getInetSocketAddress() != null) { return Sockaddr.pack_sockaddr_in(context, getInetSocketAddress()); } if (getUnixSocketAddress() != null) { return Sockaddr.pack_sockaddr_un(context, getUnixSocketAddress().path()); } return Sockaddr.pack_sockaddr_in(context, 0, "0.0.0.0"); }
protected IRubyObject getSocknameCommon(ThreadContext context, String caller) { if (getInetSocketAddress() != null) { return Sockaddr.pack_sockaddr_in(context, getInetSocketAddress()); } if (getUnixSocketAddress() != null) { return Sockaddr.pack_sockaddr_un(context, getUnixSocketAddress().path()); } return Sockaddr.pack_sockaddr_in(context, 0, "0.0.0.0"); }
@JRubyMethod public IRubyObject local_address(ThreadContext context) { Ruby runtime = context.runtime; InetSocketAddress address = getInetSocketAddress(); if (address != null) { SocketType socketType = SocketType.forChannel(getChannel()); return new Addrinfo(runtime, runtime.getClass("Addrinfo"), address, socketType.getSocketType(), socketType); } UnixSocketAddress unix = getUnixSocketAddress(); return Addrinfo.unix(context, runtime.getClass("Addrinfo"), runtime.newString(unix.path())); }
@JRubyMethod public IRubyObject local_address(ThreadContext context) { Ruby runtime = context.runtime; InetSocketAddress address = getInetSocketAddress(); if (address != null) { SocketType socketType = SocketType.forChannel(getChannel()); return new Addrinfo(runtime, runtime.getClass("Addrinfo"), address, socketType.getSocketType(), socketType); } UnixSocketAddress unix = getUnixSocketAddress(); return Addrinfo.unix(context, runtime.getClass("Addrinfo"), runtime.newString(unix.path())); }