Skip to content

Add netcode_server_create_error, distinguishing bind failures#149

Merged
gafferongames merged 1 commit into
mainfrom
server-create-error
Jul 9, 2026
Merged

Add netcode_server_create_error, distinguishing bind failures#149
gafferongames merged 1 commit into
mainfrom
server-create-error

Conversation

@gafferongames

Copy link
Copy Markdown
Contributor

Summary

Server-side mirror of netcode_client_create_error() (#148):

  • NETCODE_SERVER_CREATE_ERROR_NONE (0) — last create succeeded
  • PARSE_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 internal NETCODE_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_error covers 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

  • Local macOS: Release, Debug, ASan+UBSan pass 42/42
  • CI green on all 9 jobs

🤖 Generated with Claude Code

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>
@gafferongames gafferongames merged commit 7147721 into main Jul 9, 2026
8 checks passed
@gafferongames gafferongames deleted the server-create-error branch July 9, 2026 14:38
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