Add netcode_server_create_error, distinguishing bind failures#149
Merged
Conversation
The server-side mirror of netcode_client_create_error: each failure path in server create records a NETCODE_SERVER_CREATE_ERROR_* code, queryable via netcode_server_create_error() when create returns NULL. Bind failures are reported separately from other socket errors, per address family: a port already in use is the common operational failure for dedicated servers, and callers want to react to it (try the next port) differently than to a socket that could not be created at all. With this, create failures are queryable on both client and server. The running server intentionally has no state machine beyond netcode_server_running: its only states are stopped and started, and everything else is per-client. Adds test_server_create_error covering every reachable code, including real port-in-use bind collisions for both address families. Suite is now 42 tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Server-side mirror of
netcode_client_create_error()(#148):NETCODE_SERVER_CREATE_ERROR_NONE(0) — last create succeededPARSE_ADDRESS_FAILED(1) /PARSE_ADDRESS2_FAILED(2)CREATE_SOCKET_IPV4_FAILED(3) /CREATE_SOCKET_IPV6_FAILED(4)BIND_SOCKET_IPV4_FAILED(5) /BIND_SOCKET_IPV6_FAILED(6)ALLOCATE_SERVER_FAILED(7)Accessor:
int netcode_server_create_error(). The socket helper captures the internalNETCODE_SOCKET_ERROR_*code so bind failures are reported distinctly from other socket errors — port already in use is the common operational failure for dedicated servers, and callers want to react to it (try the next port) differently than to a socket that couldn't be created at all.test_server_create_errorcovers every reachable code, including real port-in-use bind collisions on both address families verifying the bind-vs-create distinction. Suite is now 42 tests.CLAUDE.md: with create failures queryable on both sides, the error-reporting criticism is retired — the design (state machine for async errors, create-error accessors, ignored per-packet UDP errors, server states = stopped/started only) is now documented under "what's genuinely good."
Test plan
🤖 Generated with Claude Code