AGK for Pascal
TAgkNetwork.Join Method (TAgkObject, String, Integer, String)

Joins an AGK network hosted by another app.

class function Join(const Owner: TAgkObject; const IP: String; const Port: Integer; const ClientName: String): TAgkNetwork; overload; static;
const Owner: TAgkObject 
the owner of the network object (eg. a TAgkApplication object). 
const IP: String 
The IP address of the host to connect to. 
const Port: Integer 
The port to connect to. 
const ClientName: String 
The name to use in identifying this client. 

The network is specified by IP address and port. Alternatively you may connect by network name if you are on the same LAN as the host (see the other Join overload). 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 continues to attempt to connect in the background. You can detect when a connection is made by checking that ConnectionCount is greater than 1. This app itself is included in the client count, and the host also counts as a client. If IsActive returns False at any time then the connection to the server failed and the network should be closed (by freeing this object). 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.

Copyright (c) 2012. All rights reserved.