}// CTOR private async void ConnectASync(string serverIP, int msgPort, int dataPort, int flags = -1) { try { // Create a TcpClient. Debug.Log("InputService: Connecting to to " + serverIP); connectionState = ConnectionState.Connecting; client = new StreamSocket(); await client.ConnectAsync(new HostName(serverIP), msgPort.ToString()); streamToServer = client.OutputStream.AsStreamForWrite(); // Translate the passed message into ASCII and store it as a Byte array. String message = "omicronV3_data_on," + dataPort + "," + flags; Byte[] data = System.Text.Encoding.ASCII.GetBytes(message); // Send the handshake message to the server. streamToServer.Write(data, 0, data.Length); streamToServer.Flush(); // Create the UDP socket data will be received on udpClient = new DatagramSocket(); udpClient.MessageReceived += MessageReceived; udpClient.Control.InboundBufferSizeInBytes = 15360000; await udpClient.BindServiceNameAsync(dataPort.ToString()); Debug.Log("InputService: Connected to " + serverIP); connected = true; connectionState = ConnectionState.Connected; return; } catch (Exception e) { Debug.Log("Exception: " + e); } connected = false; connectionState = ConnectionState.FailedToConnect; return; }