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/archive/2011/07/21/2113082.html