A Udp Receiver

        static void Main(string[] args)
        {
            IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
            UdpClient udpClient;
            byte[] buffer;
            string loggingEvent;

            try
            {
                udpClient = new UdpClient(8081);
                while (true)
                {
                    buffer = udpClient.Receive(ref remoteEndPoint);
                    loggingEvent = System.Text.Encoding.Unicode.GetString(buffer);
                    Console.WriteLine(loggingEvent);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
原文地址:https://www.cnblogs.com/feinian/p/2113082.html