// To copy the c++ receiver, for easier development, // there should be only one chance to send a ping. private IEnumerator Ping() { if (!UiVisibility) { print("No more than one ping at a time."); yield break; } UiVisibility = false; // The default IP address is 127.0.0.1. string ipAddressText = ipAddressInputField.text; if (ipAddressText.Length == 0) { ipAddressText = "127.0.0.1"; } // The default port is 7777. string portString = portInputField.text; int port = portString.Length != 0 ? int.Parse(portString) : 7777; string logString = $"Try connecting to {ipAddressText}:{port}..."; print(logString); statusText.text = logString; var ipAddress = IPAddress.Parse(ipAddressText); var udpSocket = new UdpSocket(new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp) { ReceiveBufferSize = 1024 * 1024 }, new IPEndPoint(ipAddress, port)); kinectReceiver.Ping(udpSocket); }