public IRubyObject allocate(Ruby runtime, RubyClass klazz) { return new Ifaddr(runtime, klazz); } });
public IRubyObject allocate(Ruby runtime, RubyClass klazz) { return new Ifaddr(runtime, klazz); } });
@JRubyMethod(meta = true) public static IRubyObject getifaddrs(ThreadContext context, IRubyObject recv) { RubyArray list = RubyArray.newArray(context.runtime); try { Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); RubyClass Ifaddr = (RubyClass) context.runtime.getClassFromPath("Socket::Ifaddr"); while (en.hasMoreElements()) { NetworkInterface ni = en.nextElement(); // create interface link layer ifaddr list.append(new Ifaddr(context.runtime, Ifaddr, ni)); for ( InterfaceAddress ia : ni.getInterfaceAddresses() ) { list.append(new Ifaddr(context.runtime, Ifaddr, ni, ia)); } } } catch (Exception ex) { if ( ex instanceof RaiseException ) throw (RaiseException) ex; throw SocketUtils.sockerr_with_trace(context.runtime, "getifaddrs: " + ex.toString(), ex.getStackTrace()); } return list; }
@JRubyMethod(meta = true) public static IRubyObject getifaddrs(ThreadContext context, IRubyObject recv) { RubyArray list = RubyArray.newArray(context.runtime); try { Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); RubyClass Ifaddr = (RubyClass) context.runtime.getClassFromPath("Socket::Ifaddr"); while (en.hasMoreElements()) { NetworkInterface ni = en.nextElement(); // create interface link layer ifaddr list.append(new Ifaddr(context.runtime, Ifaddr, ni)); for ( InterfaceAddress ia : ni.getInterfaceAddresses() ) { list.append(new Ifaddr(context.runtime, Ifaddr, ni, ia)); } } } catch (Exception ex) { if ( ex instanceof RaiseException ) throw (RaiseException) ex; throw SocketUtils.sockerr_with_trace(context.runtime, "getifaddrs: " + ex.toString(), ex.getStackTrace()); } return list; }