How To Establish A UDP Connection

After you obtain the connection endpoint along with encryption keys, you may establish a connection using UDP client as shown below:

 

When a connection is successfully established, OnCreate is raised. If it fails, OnException is raised.

int sendInterval = 200; // This is the interval in milliseconds to send packets. All packets that fall within this interval will be combined

int echoInterval = 5000; // The default is 5000 milliseconds
Diarkis.Udp udp = new Diarkis.Udp(sendInterval, echoInterval);
udp.SetClientKey(clientKey);
udp.SetEncryptionKeys(sid, key, iv, mackey);
udp.Connect(addr, port);

 

The example below will change connection methods internally if the network is IPv6 enabled. 

int sendInterval = 200; // This is the interval in milliseconds to send packets. All packets that fall within this interval will be combined

int echoInterval = 5000; // The default is 5000 milliseconds
Diarkis.Udp udp = new Diarkis.Udp(sendInterval, echoInterval);
udp.SetClientKey(clientKey);
udp.SetEncryptionKeys(sid, key, iv, mackey);
udp.ConnectDualMode(addr, port);