' Demonstrates a server that receives sound data from clients ' and relays it to other clients Imports System.Threading Module Module1 Sub Main() Dim iResult As Integer Dim RecvPacket As Int64 = mn.CreatePacket() ' Start server Console.WriteLine("Starting server...") mn.Start(1, 0) mn.SetLocal(0, "", 2525, "", 2525) mn.SetBufferSizes(0, 15000, 1024, 1) mn.StartServer(0, 50, 0, 4) Console.WriteLine("Server started") Console.WriteLine("Local TCP IP: " + mn.GetLocalIPTCP(0)) Console.WriteLine("Local TCP port: " + mn.GetLocalPortTCP(0).ToString()) Console.WriteLine("Local UDP IP: " + mn.GetLocalIPUDP(0)) Console.WriteLine("Local UDP port: " + mn.GetLocalPortUDP(0).ToString()) Console.WriteLine() ' Main loop Do Thread.Sleep(1) ' Accept new connections iResult = mn.ClientJoined(0) If iResult > 0 Then Console.WriteLine("New client joined: " + iResult.ToString()) Console.WriteLine("Client TCP IP: " + mn.GetClientIPTCP(0, iResult)) Console.WriteLine("Client TCP port: " + mn.GetClientPortTCP(0, iResult).ToString()) Console.WriteLine("Client UDP IP: " + mn.GetClientIPUDP(0, iResult)) Console.WriteLine("Client UDP port: " + mn.GetClientPortUDP(0, iResult).ToString()) End If ' Leaving clients iResult = mn.ClientLeft(0) If iResult > 0 Then Console.WriteLine("Client left: " + iResult.ToString()) End If ' New TCP packets For cl As Integer = 1 To mn.GetMaxClients(0) iResult = mn.RecvUDP(0, RecvPacket, cl, 0) If iResult > 0 Then ' Add client ID to start of packet mn.SetCursor(RecvPacket, 0) mn.Insert(RecvPacket, 4) mn.AddInt(RecvPacket, cl) ' Send packet to clients mn.SendUDPAll(0, RecvPacket, False, True, cl) End If Next cl Loop End Sub End Module