Пример #1
0
        static void Main(string[] args)
        {
            Server s = new Server(8080);

            s.MessageHandler = (b) =>
            {
                InMsg msg = new InMsg(b);
                int   x   = msg.NextInt();
                ;
            };
            s.Start();
        }
Пример #2
0
        // public void Send(byte[] b)
        // {
        //     client.GetStream().Write(b, 0, b.Length);
        // }

        public void Start()
        {
            _Work = true;

            while (_Work)
            {
                IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 14944);
                client = new UdpClient(ipep);
                IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);

                byte[] data = client.Receive(ref sender);

                InMsg msg = new InMsg(data, 4);
                MessageHandler(msg);

                client.Close();
            }
        }