Ejemplo n.º 1
0
        private void incomming(IAsyncResult res)
        {
            udpConnection con = res.AsyncState as udpConnection;

            IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, port);

            byte[] received = null;
            packetsReceived++;
            try
            {
                received = con.Client.EndReceive(res, ref RemoteIpEndPoint);
            }
            catch (Exception)
            {
            }
            try
            {
                con.Client.BeginReceive(new AsyncCallback(incomming), con);
                if (received != null)
                {
                    con.msgQueue.Enqueue(new receivedPacket()
                    {
                        received = received, endPoint = RemoteIpEndPoint
                    });
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 2
0
        public void start()
        {
            generalClient = new udpConnection()
            {
                Client = connect(port), msgQueue = new ConcurrentQueue <receivedPacket>()
            };
            generalClient.Client.BeginReceive(new AsyncCallback(incomming), generalClient);

            rxSpecificClient = new udpConnection()
            {
                Client = connect(RxSpecificPort), msgQueue = new ConcurrentQueue <receivedPacket>()
            };
            rxSpecificClient.Client.BeginReceive(new AsyncCallback(incomming), rxSpecificClient);

            txSpecificClient = new udpConnection()
            {
                Client = connect(TxSpecificPort), msgQueue = new ConcurrentQueue <receivedPacket>()
            };
            txSpecificClient.Client.BeginReceive(new AsyncCallback(incomming), txSpecificClient);

            highPriorityClient = new udpConnection()
            {
                Client = connect(HighPriorityFromPCPort), msgQueue = new ConcurrentQueue <receivedPacket>()
            };
            highPriorityClient.Client.BeginReceive(new AsyncCallback(incomming), highPriorityClient);

            tx0IQClient = new udpConnection()
            {
                Client = connect(Tx0IQPort), msgQueue = new ConcurrentQueue <receivedPacket>()
            };
            tx0IQClient.Client.BeginReceive(new AsyncCallback(incomming), tx0IQClient);

            rxAudioClient = new udpConnection()
            {
                Client = connect(ReceiverAudioPort), msgQueue = new ConcurrentQueue <receivedPacket>()
            };
            rxAudioClient.Client.BeginReceive(new AsyncCallback(incomming), rxAudioClient);


            handleCommsThread = new Thread(handleComms);
            handleCommsThread.IsBackground = true;
            handleCommsThread.Start();
        }