while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
{
data = Encoding.ASCII.GetString(bytes, 0, i);
string[] credentials = data.Split(':');
string username = credentials[0];
string password = credentials[1];
Console.WriteLine("Username: {0}", username);
Console.WriteLine("Password: {0}", password);
}
That would be the way to do it, use credentials, not data, otherwise you are just taking the first and second letter of the data.