Skip to content

Add IPv4 socket support across backends and socket API - #62

Merged
lePereT merged 1 commit into
nextfrom
tcp_sockets
Feb 24, 2026
Merged

lePereT merged 1 commit into
nextfrom
tcp_sockets

Conversation

@lePereT

@lePereT lePereT commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this? (check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • ✅ Test

Description

Adds IPv4 socket support to fibers.io.socket and updates the FFI, nixio, and posix fd backends to accept a common sockaddr token format for UNIX and INET sockets.

Also tightens backend error handling by normalising nixio return signatures (msg, errno vs errno, msg) and fixes nixio directory mode handling so mkdir() permissions work reliably across builds.

Changes

  • Export AF_INET from fd_backend.core (and backend modules)

  • Add AF_INET support to fd_backend/ffi.lua (sockaddr_in, inet_pton, htons, bind/connect support)

  • Extend fd_backend/nixio.lua:

    • INET/INET6 sockaddr normalisation
    • bind/connect support for UNIX/INET/INET6
    • normalised error parsing across nixio APIs
    • mkdir() permission handling using octal strings for nixio compatibility
  • Extend fd_backend/posix.lua:

    • sockaddr normalisation for UNIX/INET/INET6
    • INET/INET6 metadata exports
    • more tolerant non-blocking connect handling (EINPROGRESS / EALREADY / EAGAIN)
  • Extend fibers.io.socket:

    • generic :bind() / :listen()
    • listen_inet() / connect_inet() convenience helpers
    • Socket:bind_inet() / Socket:listen_inet() / Socket:connect_inet()
    • export AF_INET
  • Update tests/test_io-socket.lua:

    • retain AF_UNIX roundtrip test
    • add AF_INET loopback roundtrip test (server + client, explicit source bind)
    • small test helper cleanup (read_exact, write_all, close_ok)

Related Issues, Tickets & Documents

N/A

Screenshots/Recordings

N/A (no UI changes)

Manual test

  • 👍 yes

Manual test description

Ran tests/test.lua.

Added tests?

  • 👍 yes

Extended tests/test_io-socket.lua with both AF_UNIX and AF_INET tests. Confirmed successful client/server roundtrip on:

  • UNIX domain socket
  • IPv4 loopback (127.0.0.1) with explicit client source bind

Added to documentation?

  • 🙅 no documentation needed

[optional] Are there any post-deployment tasks we need to perform?

None.

@lePereT
lePereT merged commit 8204713 into next Feb 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant