/// <summary> /// Reads in a message from the stream and parses it. /// </summary> /// <returns>a byte array containing a message</returns> private byte[] ReadInMessage() { List <char> integerStringList = new List <char>(); char character = serverConnection.ReadByte(); while (character != ':') { integerStringList.Add(character); character = serverConnection.ReadByte(); } int length = int.Parse(new string(integerStringList.ToArray())); byte[] data = new byte[length]; serverConnection.Read(data, 0, data.Length); return(data); }