To host a multiplayer game, one player must set up a server that listens for incoming connections. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/korrykatti/game/llms.txt
Use this file to discover all available pages before exploring further.
SetupHost() function handles all server initialization.
How hosting works
Configure the server address
The server binds to all available network interfaces on the specified port:
main.cpp
ENET_HOST_ANY allows the server to accept connections on any network interface.Create the ENet host
Create the server host with the following parameters:Parameters:
main.cpp
- Max clients:
1- Only one client can connect for 1v1 gameplay - Max channels:
2- Two communication channels available - Bandwidth limits:
0- No bandwidth restrictions
Verify host creation
Check if the host was created successfully:If creation fails, the function returns
main.cpp
false and the game returns to the main menu.Complete SetupHost function
main.cpp
Network variables
The following global variables manage the host connection:main.cpp
When hosting, the server uses
serverHost to manage the connection and stores the connected client in clientPeer.