Skip to content

examples: Add LAN discovery beacon and server browser (Issue #82) - #448

Open
sashakosti wants to merge 2 commits into
ValveSoftware:masterfrom
sashakosti:feat/lan-discovery
Open

sashakosti wants to merge 2 commits into
ValveSoftware:masterfrom
sashakosti:feat/lan-discovery

Conversation

@sashakosti

Copy link
Copy Markdown

Resolves #82.

Adds a lightweight, self-contained UDP broadcast discovery module for finding GameNetworkingSockets servers on the local area network.

Overview

  • examples/lan_discovery.h / lan_discovery.cpp:
    • CLanBeacon: Background broadcaster announcing server availability, port, and game metadata.
    • CLanBrowser: Active query/response client discovering local servers with query retries and address ranking (prefers routable LAN IPs over loopback/link-local).
  • examples/example_chat.cpp:
    • Demonstrates usage via --lan-announce (host) and --lan-find (client auto-discovery and connection).
  • Windows and POSIX non-blocking UDP socket compatibility (ScopedWinsockInit_t, SO_BROADCAST).
  • Zero changes to core engine/library ABI.

…e_chat

- Implements lightweight UDP-based discovery beacon (CLanDiscoveryBeacon)
  and client utility (CLanDiscoveryClient) on port 27015.
- example_chat server advertises its listen port and responds to discovery queries.
- example_chat client auto-discovers and connects to the local server when no
  address argument is provided.
- Responds to mobile/external GNS_PING probes with GNS_PONG.

Closes ValveSoftware#82
…dress ranking

- Eliminate double-close and cross-thread socket data race in beacon teardown.
- Retransmit discovery query every 500ms to tolerate packet loss on wireless LANs.
- Prioritize routable physical LAN interfaces over internal container bridges.
- Add ScopedWinsockInit guard on Windows.
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.

Feature Request: LAN Discovery

1 participant