using (var connection = new TcpClientConnection()) using (var data = new MemoryStream()) { connection.NetworkStream = new NetworkStream(); connection.Open(HostResolver.GetIPAddress("192.168.1.1"), 12345); //open the connection connection.ReadData(data); //read two bytes with the size information data.Seek(0, SeekOrigin.Begin); var bytes = new byte[2]; data.Read(bytes, 0, 2); int dataSize = bytes[1] + bytes[0] << 8; //decode the data size data.Seek(0, SeekOrigin.End); //move to the end of the stream and read the rest of data while (data.Length < dataSize + 2) { //two bytes with the size information are not included in data connection.ReadData(data); } data.Seek(2, SeekOrigin.Begin); //skip two bytes with the size before extracting data bytes = new byte[dataSize]; data.Read(bytes, 0, dataSize); //the received bytes }
Trouble logging in? Simply enter your email address OR username in order to reset your password.
For faster and more reliable delivery, add admin@clevercomponents.com to your trusted senders list in your email software.