# HostNetwork

## Description

Creates an AGK network with this app as the controller, this app is added as the first client to the network. AGK networks are identified by name and are automatically broadcast to anyone listening on the local area network, meaning that other AGK apps on the LAN can pick up all broadcast networks, display their names to their users and allow them to choose one to join. AGK apps outside the LAN need the IP address and port of the hoster to join the network, this port will need forwarding to the host through any intervening firewall. The port value must be between 1025 and 65535, and will fail if another application is already listening on that port.
You must also specify a client name to use to identify your client, all client names must be unique. This name will be visible to all other clients. Clients will be added to the network automatically and can be counted using GetNetworkNumClients. You can call IsNetworkActive immediately after this command to check that the network was setup successfully, once setup the network will not become inactive for a hoster.
Once connected the app becomes a client of the network, any other clients that connect to it join the network. All clients are treated equally and have a list of local variables that they can read from and write to, all clients can also read any variables on other clients on a read only basis.
Some ports are used by AGK for internal networking and should not be used by your application. Port 5689 is used to manage apps broadcasted from the T1 IDE. Port 45631 is used for named network connections. Port 45633 is used for file broadcasting and port 45635 is used by the AGK Viewer to stream content and input data between device and the IDE when native execution is not possible on the device itself.
Returns an ID you can use to interact with this network.
Does not work when exported to HTML5

## Definition

integer HostNetwork( szNetworkName, szMyName, port )

UINT agk::HostNetwork( const char *szNetworkName, const char *szMyName, UINT port )

## Parameters

- szNetworkName - The name to use in identifying this network.
- szMyName - The name to use in identifying this client.
- port - The port that other clients should use to connect to this network.