25 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 43c0b50cbd mruby-socket: implement Socket.ip_address_list
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>
2026-05-09 10:22:19 +09:00
Yukihiro "Matz" Matsumoto 550be1445f Revert "mruby-socket: add temporary getaddrinfo diagnostic for Windows CI"
This reverts commit a69d12aa54.

The diagnostic served its purpose: it isolated the failure to
Winsock's getaddrinfo for the "localhost" hostname. The permanent
fix (skip guard) is now in place, so remove the temporary probe.

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-24 08:19:04 +09:00
Yukihiro "Matz" Matsumoto 57ca531f76 mruby-socket: skip localhost-dependent addrinfo tests on Windows
Addrinfo.getaddrinfo("localhost", ...) and Addrinfo.foreach("localhost",
...) crash on GitHub Actions Windows runners (Windows Server 2022 and
2025, both mingw-gcc and MSVC). Diagnostic showed 127.0.0.1 as a
numeric literal resolves fine via Winsock getaddrinfo, but "localhost"
as a hostname returns WSAHOST_NOT_FOUND under every address family
(AF_INET, AF_INET6, AF_UNSPEC, nil). PowerShell Resolve-DnsName on
the same runner succeeds, so the failure is Winsock-specific rather
than OS-level. Earlier workarounds (Dnscache service start, hosts
file append) had no effect.

Skip both tests on Windows with the existing SocketTest.win? guard,
matching the pattern already used for Addrinfo.unix and
Addrinfo#afamily. Linux and macOS coverage is unaffected.

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-24 08:18:41 +09:00
Yukihiro "Matz" Matsumoto a69d12aa54 mruby-socket: add temporary getaddrinfo diagnostic for Windows CI
Addrinfo.getaddrinfo("localhost", 53, AF_INET, SOCK_STREAM) crashes
on GitHub Actions Windows runners with WSAHOST_NOT_FOUND, while the
same call works on Linux and macOS. Earlier hypotheses (winsock link
missing; hosts file not populated) have been ruled out on CI.

Probe five variants in one run to isolate the failing condition:
numeric literal 127.0.0.1, localhost with AF_UNSPEC, localhost with
nil family, localhost with AF_INET6, and the original AF_INET path.
Results go to stdout via puts so they are visible in CI logs. This
commit is temporary and will be reverted once the real fix lands.

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-24 01:20:15 +09:00
dearblue 1326017d1d Omit the _WIN64 definition check
Checking the official MSVC documentation, if `_WIN64` is defined, then `_WIN32` is also defined.
https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros

I could not find any documentation on MinGW, but I assume it is not a problem.
2024-12-07 22:47:28 +09:00
Yukihiro "Matz" Matsumoto 87b358a342 Including header files in include/* by <> 2024-03-26 13:59:59 +09:00
dearblue cc1db2d117 Remove unnecessary 'stdio.h'; ref #4947
'stdio.h' is included in 'mruby.h' ('mrbconf.h').

However, keep 'stdio.h' used by mruby-test.
2020-03-08 21:42:09 +09:00
dearblue 8020374d6b Fix builds for old mingw in mruby-socket; ref #4914 2020-02-01 15:58:32 +09:00
KOBAYASHI Shuji d68eb3d043 Fix wrong assertion method in some tests 2019-02-18 21:24:20 +09:00
Yukihiro "Matz" Matsumoto a657117e4e Avoid warning in MSVC compilation. 2018-09-01 17:36:35 +09:00
Sebastián Katzer 0bc8d1979c Network services might not be available 2018-07-21 10:18:22 +02:00
Yukihiro "Matz" Matsumoto e02cbb4426 Need fcntl.h and sys/stat.h as well for _open; ref #3938 2018-02-02 14:58:09 +09:00
Yukihiro "Matz" Matsumoto c9fa7b1919 Need to include io.h anyway for _WIN32/64; ref #3938 2018-02-02 14:18:25 +09:00
Yasuhiro Matsumoto 0e0dad7697 include io.h on mingw 2018-01-31 12:18:35 +09:00
Yukihiro "Matz" Matsumoto f7ff2d0ee3 Define compatibility only for _MSC_VER; ref #3923
Suggested by @mattn.
2018-01-31 12:10:51 +09:00
ksss e422ba0bff Use mkstemp instead of tempnam 2018-01-31 11:34:29 +09:00
Hiroshi Mimaki f55df0da7b addrinfo.ai_protocol was not set on Cygwin. 2017-12-26 11:12:49 +09:00
Hiroshi Mimaki bce811a53a Disabled UNIXSocket test on Cygwin 2017-12-26 11:05:28 +09:00
Yukihiro "Matz" Matsumoto 69ad12de06 Exclude UNIXSocket tests again; ref #3878 2017-12-14 00:05:23 +09:00
Takeshi Watanabe 949bf6ca43 Fix socket closing by using closesocket API in windows instead. 2017-12-14 00:05:23 +09:00
Yukihiro "Matz" Matsumoto 55fced30cd Use _tempnam instead of tempnam on Windows. 2017-12-13 14:17:49 +09:00
Hiroshi Mimaki 4353623b72 Skip tests on Windows platform 2017-12-13 13:02:59 +09:00
Yukihiro "Matz" Matsumoto 761218e70b Skip socket tests on Windows platform.
Some test may be OK but we skip everything as a starting point.
2017-12-09 14:22:53 +09:00
Takeshi Watanabe 5de7dc2948 Fix memory leak found by leak sanitizer. 2017-12-08 12:10:28 +09:00
Yukihiro "Matz" Matsumoto 73ef548c63 Add 'mrbgems/mruby-socket/' from commit 'ab54185005ec87fe4f5b10df95ad29659884141b'
git-subtree-dir: mrbgems/mruby-socket
git-subtree-mainline: d75266dd1b
git-subtree-split: ab54185005
2017-12-07 18:11:13 +09:00