JoinNetwork - AGK Help

JoinNetwork

Description

Joins an AGK network hosted by another app. The network is specified by IP address and port, alternatively you may connect by network name if you on the same LAN as the host. In the case of internet connections IP and port is the only way to connect as broadcasts will not leave the local area network.

This function does not connect immediately, it returns a network ID and continues to attempt to connect in the background. You can detect when a connection is made by checking that GetNetworkNumClients is greater than 1. This app itself is included in the client count, and the host also counts as a client. If IsNetworkActive returns 0 at any time then the connection to the server failed and the network should be closed, you may attempt to reconnect by opening a new network.

Once connected the app becomes a client of the network, along with the host and any other clients that have connected to it. 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.

Returns a network ID to use when interacting with this network.

Does not work when exported to HTML5

Definition

integer JoinNetwork( szIP, port, szMyName )

integer JoinNetwork( szNetworkName, szMyName )

Parameters