[#54738] [ruby-trunk - Bug #8358][Open] TestSprintf#test_float test failuer on mingw32 — "phasis68 (Heesob Park)" <phasis@...>

36 messages 2013/05/02

[#54749] [ruby-trunk - Feature #8361][Open] Alternative syntax for block parameter — "alexeymuranov (Alexey Muranov)" <redmine@...>

12 messages 2013/05/02

[#54798] [ruby-trunk - Bug #8370][Open] Constants MAX_MULTIPART_LENGTH in cgi\core.rb — "xibbar (Takeyuki FUJIOKA)" <xibbar@...>

17 messages 2013/05/05

[#54850] [ruby-trunk - Feature #8377][Open] Deprecate :: for method calls in 2.1 — "charliesome (Charlie Somerville)" <charliesome@...>

27 messages 2013/05/07

[#54881] [ruby-trunk - Bug #8384][Open] Cannot build ruby against OpenSSL build with "no-ec2m" — "vo.x (Vit Ondruch)" <v.ondruch@...>

16 messages 2013/05/09

[#54921] [ruby-trunk - Bug #8393][Open] A class who's parent class is in a module can go wrong if files are required in the wrong order — "eLobato (Daniel Lobato Garcia)" <elobatocs@...>

15 messages 2013/05/12

[#54939] [ruby-trunk - Bug #8399][Open] Remove usage of RARRAY_PTR in C extensions when not needed — "dbussink (Dirkjan Bussink)" <d.bussink@...>

32 messages 2013/05/12

[#55053] [ruby-trunk - Feature #8426][Open] Implement class hierarchy method caching — "charliesome (Charlie Somerville)" <charliesome@...>

21 messages 2013/05/19

[#55096] [ruby-trunk - Feature #8430][Open] Rational number literal — "mrkn (Kenta Murata)" <muraken@...>

28 messages 2013/05/21

[#55197] [ruby-trunk - Feature #8461][Open] Easy way to disable certificate checking in XMLRPC::Client — "herwinw (Herwin Weststrate)" <herwin@...>

11 messages 2013/05/29

[ruby-core:54805] Re: [ruby-trunk - Feature #8368][Open] Socket.getifaddrs

From: Magnus Holm <judofyr@...>
Date: 2013-05-05 16:01:52 UTC
List: ruby-core #54805
Shouldn't this be moved to CommonRuby?

On Sunday, May 5, 2013, naruse (Yui NARUSE) wrote:

>
> Issue #8368 has been updated by naruse (Yui NARUSE).
>
> Target version set to current: 2.1.0
>
> I'm for this method.
> ----------------------------------------
> Feature #8368: Socket.getifaddrs
> https://bugs.ruby-lang.org/issues/8368#change-39144
>
> Author: akr (Akira Tanaka)
> Status: Open
> Priority: Normal
> Assignee:
> Category:
> Target version: current: 2.1.0
>
>
> I'd like to add a method: Socket.getifaddrs.
>
> This method is a wrapper to getifaddrs() function.
> The result is an array of instances of Socket::Ifaddr class as follows.
>
>   % ./ruby -rpp -rsocket -e 'pp Socket.getifaddrs'
>   [#<Socket::Ifaddr lo UP,LOOPBACK,RUNNING,0x10000 [PACKET protocol:0 lo
> hatype:772 HOST hwaddr:00:00:00:00:00:00]>,
>    #<Socket::Ifaddr eth0 UP,BROADCAST,RUNNING,MULTICAST,0x10000 [PACKET
> protocol:0 eth0 hatype:1 HOST hwaddr:00:16:3e:95:88:bb] broadcast:[PACKET
> protocol:0 eth0 hatype:1 HOST hwaddr:ff:ff:ff:ff:ff:ff]>,
>    #<Socket::Ifaddr sit0 NOARP [PACKET protocol:0 sit0 hatype:776 HOST
> hwaddr:00:00:00:00]>,
>    #<Socket::Ifaddr lo UP,LOOPBACK,RUNNING,0x10000 [127.0.0.1]
> netmask:[255.0.0.0]>,
>    #<Socket::Ifaddr eth0 UP,BROADCAST,RUNNING,MULTICAST,0x10000
> [221.186.184.67] netmask:[255.255.255.240] broadcast:[221.186.184.79]>,
>    #<Socket::Ifaddr lo UP,LOOPBACK,RUNNING,0x10000 [::1]
> netmask:[ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]>,
>    #<Socket::Ifaddr eth0 UP,BROADCAST,RUNNING,MULTICAST,0x10000
> [fe80::216:3eff:fe95:88bb%eth0] netmask:[ffff:ffff:ffff:ffff::]>]
>
> This method can be used to choose multicast-enabled interfaces.
> Multicast applications needs to identify a such interface to sending a
> multicast datagram.
>
>   % ./ruby -rpp -rsocket -e '
>   pp Socket.getifaddrs.reject {|ifaddr|
>     !ifaddr.addr.ip? || (ifaddr.flags & Socket::IFF_MULTICAST == 0)
>   }.map {|ifaddr| [ifaddr.name, ifaddr.ifindex, ifaddr.addr] }'
>   [["eth0", 2, #<Addrinfo: 221.186.184.67>],
>    ["eth0", 2, #<Addrinfo: fe80::216:3eff:fe95:88bb%eth0>]]
>
> This method can be used to obtain broadcast addresses to send a broadcast
> messages.  (use case: [ruby-talk:329921])
>
> Also, the broadcast addresses can be used to receive broadcast messages.
> (Programming UNIX Sockets in C: 4.12.  How can I write a multi-homed
> server?
>  http://www.faqs.org/faqs/unix-faq/socket/ )
>
> getifaddrs() is not standardized but many platforms have.
> BSDI, FreeBSD, NetBSD, OpenBSD, DragonFly, MirOS, GNU/Linux, MacOS X,
> SunOS 5.11 (OpenIndiana), Cygwin 1.7.15
>
> From Gnulib document, getifaddrs() is not exist on
> AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw,
> MSVC 9, Interix 3.5, BeOS.
> http://www.gnu.org/software/gnulib/manual/html_node/getifaddrs.html
>
> I implemented new Socket::Ifaddr class for return value of
> Socket.getifaddrs,
> instead of constructing the result from currentn data structures such as
> Array.
> This choice make us possible to implement Socket::Ifaddr#inspect to show
> flags as its names (UP,...).
> Also, struct getifaddrs contains Address-specific data, ifa_data which may
> be extended by platforms.
> When we find a way to extract some data from ifa_data, we can add a method
> for that.
>
> Socket::Ifaddr is different from Socket::Interface by
> http://bugs.ruby-lang.org/issues/8075 .
> They have no one-to-one mapping.
> For example, Socket.getifaddrs returns two or more elements for one
> interface.
>
>
>
>
> --
> http://bugs.ruby-lang.org/
>
>

-- 

// Magnus Holm

In This Thread