public static InetSocketAddress addressFromArg(ThreadContext context, IRubyObject arg) { InetSocketAddress iaddr; if (arg instanceof Addrinfo) { Addrinfo addrinfo = (Addrinfo)arg; iaddr = new InetSocketAddress(addrinfo.getInetAddress(), addrinfo.getPort()); } else { iaddr = addressFromSockaddr_in(context, arg); } return iaddr; }
public static InetSocketAddress addressFromArg(ThreadContext context, IRubyObject arg) { InetSocketAddress iaddr; if (arg instanceof Addrinfo) { Addrinfo addrinfo = (Addrinfo)arg; if (!addrinfo.ip_p(context).isTrue()) { throw context.runtime.newTypeError("not an INET or INET6 address: " + addrinfo); } iaddr = new InetSocketAddress(addrinfo.getInetAddress(), addrinfo.getPort()); } else { iaddr = addressFromSockaddr_in(context, arg); } return iaddr; }
public static InetSocketAddress addressFromArg(ThreadContext context, IRubyObject arg) { InetSocketAddress iaddr; if (arg instanceof Addrinfo) { Addrinfo addrinfo = (Addrinfo)arg; if (!addrinfo.ip_p(context).isTrue()) { throw context.runtime.newTypeError("not an INET or INET6 address: " + addrinfo); } iaddr = new InetSocketAddress(addrinfo.getInetAddress(), addrinfo.getPort()); } else { iaddr = addressFromSockaddr_in(context, arg); } return iaddr; }
@JRubyMethod() public IRubyObject bind(ThreadContext context, IRubyObject addr, IRubyObject backlog) { final InetSocketAddress iaddr; if (addr instanceof Addrinfo) { Addrinfo addrInfo = (Addrinfo) addr; if (!addrInfo.ip_p(context).isTrue()) { throw context.runtime.newTypeError("not an INET or INET6 address: " + addrInfo); } iaddr = new InetSocketAddress(addrInfo.getInetAddress().getHostAddress(), addrInfo.getPort()); } else { iaddr = Sockaddr.addressFromSockaddr_in(context, addr); } doBind(context, getChannel(), iaddr, RubyFixnum.fix2int(backlog)); return RubyFixnum.zero(context.runtime); }
@JRubyMethod() public IRubyObject bind(ThreadContext context, IRubyObject addr, IRubyObject backlog) { final InetSocketAddress iaddr; if (addr instanceof Addrinfo) { Addrinfo addrInfo = (Addrinfo) addr; if (!addrInfo.ip_p(context).isTrue()) { throw context.runtime.newTypeError("not an INET or INET6 address: " + addrInfo); } iaddr = new InetSocketAddress(addrInfo.getInetAddress().getHostAddress(), addrInfo.getPort()); } else { iaddr = Sockaddr.addressFromSockaddr_in(context, addr); } doBind(context, getChannel(), iaddr, RubyFixnum.fix2int(backlog)); return RubyFixnum.zero(context.runtime); }
@JRubyMethod(optional = 1) public IRubyObject getnameinfo(ThreadContext context, IRubyObject[] args) { Ruby runtime = context.runtime; RubyString hostname; InetSocketAddress inet = getInetSocketAddress(); if (inet != null) { hostname = runtime.newString(inet.getHostName()); } else { UnixSocketAddress unix = getUnixSocketAddress(); hostname = runtime.newString(unix.path()); } RubyString rubyService = null; if (args.length > 0) { int flags = args[0].convertToInteger().getIntValue(); if ((flags & NameInfo.NI_NUMERICSERV.intValue()) != 0) { rubyService = runtime.newString(Integer.toString(getPort())); } } if (rubyService == null) { Service service = Service.getServiceByPort(getPort(), protocol.getName()); rubyService = runtime.newString(service.getName()); } return runtime.newArray(hostname, rubyService); }
@JRubyMethod(optional = 1) public IRubyObject getnameinfo(ThreadContext context, IRubyObject[] args) { Ruby runtime = context.runtime; RubyString hostname; InetSocketAddress inet = getInetSocketAddress(); if (inet != null) { hostname = runtime.newString(inet.getHostName()); } else { UnixSocketAddress unix = getUnixSocketAddress(); hostname = runtime.newString(unix.path()); } RubyString rubyService = null; if (args.length > 0) { int flags = args[0].convertToInteger().getIntValue(); if ((flags & NameInfo.NI_NUMERICSERV.intValue()) != 0) { rubyService = runtime.newString(Integer.toString(getPort())); } } if (rubyService == null) { Service service = Service.getServiceByPort(getPort(), protocol.getName()); rubyService = runtime.newString(service.getName()); } return runtime.newArray(hostname, rubyService); }