Ejemplo n.º 1
0
            // Constructor
            public UDPReceiver(NetworkComponents.MessageProc messageProc)
            {
                this.messageProc = messageProc;

                this.udpClient = new UdpClient();
                this.udpClient.Client.ReceiveTimeout = 250;
                this.udpClient.ExclusiveAddressUse = false;
                this.localEndPoint = new IPEndPoint(IPAddress.Any, NetworkComponents.gamePort);
                this.udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
                this.udpClient.ExclusiveAddressUse = false;
                this.udpClient.Client.Bind(this.localEndPoint);
                this.udpClient.JoinMulticastGroup(IPAddress.Parse(NetworkComponents.multicastIP), 50);

                this.receiverThread = new Thread(this.Receive);
                this.receiverThread.Name = "Gridforce UDP Receiver";
                this.receiverThread.IsBackground = true;
                this.receiverThread.Start();
            }
Ejemplo n.º 2
0
            private NetworkComponents.MessageProc messageProc = null;		// Message to call on receiving message

            // Constructor
            public UDPReceiver(NetworkComponents.MessageProc messageProc)
            {
                this.messageProc = messageProc;
                Task task = Task.Run(async () => { await this.Connect(); });
                task.Wait();
            }