Returns an Array of Addrinfo objects for all local IP addresses
(IPv4 and IPv6) on every network interface, matching CRuby's API.
Backed by getifaddrs(3) on POSIX and GetAdaptersAddresses on
Windows (requires iphlpapi.lib, added to the Windows linker libs).
The HAL returns binary sockaddr strings; src/socket.c wraps each
into Addrinfo so the wrapping code stays platform-agnostic.
Resolves the second error reported in #5659 (after the IO.select
fix from the HAL split): "undefined method 'ip_address_list' for
Class". Issue #5659 itself is closed; this lands the missing API.
Ref #5659.
Co-authored-by: Claude <noreply@anthropic.com>
The s = self workaround and XXX comment in recvfrom_nonblock date back
to the initial import of mruby-socket. The underlying bug where self
became a SystemcallException inside ensure blocks has since been fixed.
Verified that self correctly refers to the socket object in ensure
blocks after exceptions from recvfrom.
Added complete call-seq documentation for socket programming methods across
all major socket classes in both mrblib/socket.rb (64 Ruby methods) and
src/socket.c (35 C methods):
- Addrinfo: Complete documentation for address information handling including
creation (new, foreach, ip, tcp, udp, unix), inspection (inspect,
inspect_sockaddr, to_s), address queries (afamily, pfamily, ipv4?, ipv6?,
ip?, unix?), data extraction (ip_address, ip_port, ip_unpack, unix_path),
and conversion methods (to_sockaddr, getnameinfo)
- BasicSocket: Core socket functionality including class configuration
(do_not_reverse_lookup, do_not_reverse_lookup=), object creation (for_fd),
address retrieval (local_address, remote_address), and non-blocking
operations (recv_nonblock)
- IPSocket: Internet protocol socket operations including address information
(addr, peeraddr), connection methods (bind, connect), data transfer
(send, recvfrom, recvfrom_nonblock), and address resolution (getaddress)
- TCPSocket/TCPServer: TCP client and server socket operations including
connection establishment (new, open), server operations (accept,
accept_nonblock, listen, sysaccept)
- UDPSocket: UDP socket operations for datagram communication including
initialization and internal address handling
- Socket: Low-level socket operations including creation (new, open),
address manipulation (sockaddr_in, sockaddr_un, unpack_sockaddr_in,
unpack_sockaddr_un), connection management (bind, connect, listen),
data transfer (recvfrom, recvfrom_nonblock), socket pairs (pair),
and name resolution (getaddrinfo, getnameinfo)
- UNIXSocket/UNIXServer: Unix domain socket operations for local IPC
including creation (new, socketpair), path handling (path, addr, peeraddr),
server operations (accept, accept_nonblock, listen, sysaccept), and
data transfer (recvfrom)
- Addrinfo: Core address resolution methods including getaddrinfo for name
resolution, getnameinfo for reverse lookups, and unix_path for Unix
domain socket paths
- BasicSocket: Low-level socket operations including getpeereid for peer
credentials, getpeername/getsockname for address retrieval, recv/send
for data transfer, getsockopt/setsockopt for option management,
shutdown for connection termination, and Windows-specific overrides
(close, sysread, sysseek, syswrite)
- IPSocket: Internet protocol utilities including ntop/pton for address
conversion and recvfrom for receiving data with sender information
- Socket: Core socket creation and management including gethostname,
internal methods (_accept, _bind, _connect, _listen, _socket),
address utilities (sockaddr_un, socketpair), and platform-specific
implementations
- Socket::Option: Socket option handling including creation from boolean/
integer values, accessor methods (family, level, optname, data),
type conversion (int, bool), and debugging support (inspect)
All methods now have comprehensive call-seq documentation with practical
This significantly improves maintainability and usability of errno
handling for developers working with system call errors and file
operations in embedded Ruby environments.
Co-authored-by: Atlassian Rovo Dev