public void Loop() { StreamReader input = new StreamReader(Console.OpenStandardInput()); Char[] buffer = new Char[1024]; ReadLine read = Console.ReadLine; IAsyncResult result = null; UdpConnection connection = null; UdpEvent ev; while (true) { while (socket.Poll(out ev)) { switch (ev.EventType) { case UdpEventType.Connected: UdpLog.User("Connected to server at {0}", ev.Connection.RemoteEndPoint); connection = ev.Connection; break; case UdpEventType.Disconnected: UdpLog.User("Disconnected from server at {0}", ev.Connection.RemoteEndPoint); connection = null; break; case UdpEventType.ObjectReceived: Console.WriteLine(": " + (ev.Object as string)); break; } } if (result == null) { result = read.BeginInvoke(null, null); } if (result.IsCompleted) { if (connection != null) { connection.Send(read.EndInvoke(result)); } result = read.BeginInvoke(null, null); } // Simulate ~60fps game loop Thread.Sleep(16); } }