sock v0.3.1 — Adaptive I/O refactor #31
hayabusa-cloud
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Introduction
sockis a zero-allocation socket library for Go, providing TCP, UDP, Unix, SCTP, and raw socket types built directly on thezcallassembly syscall package. All sockets are created withSOCK_NONBLOCKandSOCK_CLOEXECflags and returniofd.FDfile descriptors for integration withio_uringasync I/O. Address serialization is zero-allocation, encoding directly into kernelsockaddrstructures without intermediate heap objects.SO_ZEROCOPY,SCM_RIGHTSfile descriptor passing,TCP_INFOdiagnostics, multicast group management, and UDP batch operations viasendmmsg/recvmmsg.Usage
TCP echo with adaptive I/O
UDP datagram exchange
Highlights
This release refactors the adaptive I/O layer to handle
ErrInterrupted(EINTR) uniformly across all operation types, splits Unix domain socket address encoding by platform for correctness on Linux versus BSD/Darwin, fixes SCTP_CONTEXT to use the correctsctp_assoc_valuekernel structure, and adds a comprehensive examples package.What's Changed
Bug Fixes
Set/Getto usesctp_assoc_valuestructure instead of plain int, matching the Linux kernel ABI (fix: tighten edge-case contracts for Unix, SCTP, and adaptive I/O #29)io.EOFonly forSOCK_STREAM;SOCK_DGRAMandSOCK_SEQPACKETnow correctly return(0, nil)for empty messages (fix: tighten edge-case contracts for Unix, SCTP, and adaptive I/O #29)ErrAddressFamilyNotSupported(fix: tighten edge-case contracts for Unix, SCTP, and adaptive I/O #29)"unix","unixgram","unixpacket") throughdecodeUnixAddrvia newunixSocketNetworkhelper (fix: tighten edge-case contracts for Unix, SCTP, and adaptive I/O #29)Features
retryInterruptedhelper to restart syscalls on EINTR; applied to all adaptive paths (read, write, accept) (fix: tighten edge-case contracts for Unix, SCTP, and adaptive I/O #29, fix: consolidate adaptive I/O EINTR retry logic #30)adaptiveReadMsgandadaptiveWriteMsgvariants for UDP message operations (ReadFromUDP,WriteToUDP,ReadMsgUDP,WriteMsgUDP), replacing inline retry loops (fix: consolidate adaptive I/O EINTR retry logic #30)examples/with TCP client/server, UDP unicast/multicast, event loop, and stream helper examples as executable test files (feat: add user-facing TCP, UDP, and event-loop examples #28)Improvements
sockaddr_unix_linux.go,sockaddr_unix_bsd.go) withencodeUnixSockaddrPathandunixSockaddrPath(fix: tighten edge-case contracts for Unix, SCTP, and adaptive I/O #29)SockaddrToTCPAddr,SockaddrToUDPAddrhelpers (fix: tighten edge-case contracts for Unix, SCTP, and adaptive I/O #29)Compatibility
This discussion was created from the release sock v0.3.1 — Adaptive I/O refactor.
Beta Was this translation helpful? Give feedback.
All reactions