Skip to content

feat: add native socket RAII wrapper - #7

Merged
zuudevs merged 5 commits into
mainfrom
feat/native-socket
Sep 14, 2026
Merged

zuudevs merged 5 commits into
mainfrom
feat/native-socket

Conversation

@zuudevs

@zuudevs zuudevs commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the first platform networking primitive for v1: an internal move-only RAII wrapper around native socket handles.

Added

  • src/platform/native_socket.hpp
    • internal NativeSocketHandle abstraction
    • Windows SOCKET / POSIX file-descriptor invalid-state handling
    • move-only NativeSocket
    • valid(), get(), release(), reset(), and close()
    • last_socket_error() platform diagnostic helper
  • src/platform/native_socket.cpp
    • closesocket() on Windows
    • close() on POSIX
    • deterministic destructor cleanup
  • tests/native_socket_test.cpp
    • invalid/default state
    • move construction and move assignment
    • replacement-handle cleanup
    • release() ownership transfer
    • explicit reset/close behavior
    • destructor closes the owned native handle

Build changes

  • compile the platform socket implementation into the internal target
  • link Ws2_32 only on Windows
  • allow internal platform tests to include src/ privately

Architecture alignment

This keeps native socket types entirely behind the implementation boundary. No Winsock/POSIX types are added to the public API, and transport/DNS/HTTP semantics remain out of this layer.

Scope

This PR intentionally does not implement DNS resolution, socket creation policy, TCP connect, timeouts, send/receive loops, or Client behavior. Those build on this ownership primitive in follow-up PRs.

@zuudevs
zuudevs merged commit 0ece45e into main Sep 14, 2026
6 checks passed
@zuudevs
zuudevs deleted the feat/native-socket branch September 14, 2026 14:19
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