Ejemplo n.º 1
0
        private void ReceptionCallback(IAsyncResult ar)
        {
            try
            {
                UdpClient u = (UdpClient)((UdpState)(ar.AsyncState)).u;

                IPEndPoint e = new IPEndPoint(IPAddress.Any, PortEntree);

                Byte[] receiveBytes = u.EndReceive(ar, ref e);

                ConnexionCheck.MajConnexion();

                Trame trameRecue = new Trame(receiveBytes);
                if (trameRecue.ToString() == "C2 A1 C5")
                    trameRecue = new Trame("C2 A1 C3");
                TrameRecue(trameRecue);

                UdpState s = new UdpState();
                s.e = e;
                s.u = u;
                u.BeginReceive(ReceptionCallback, s);
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Lance la réception de trames sur le port actuel
        /// </summary>
        public override void StartReception()
        {
            e = new IPEndPoint(IPAddress.Any, PortEntree);
            if (u != null)
                u.Close();
            u = new UdpClient(e);

            UdpState s = new UdpState();
            s.e = e;
            s.u = u;
            u.BeginReceive(new AsyncCallback(ReceptionCallback), s);
        }