So I am having trouble reading my string sent through a Tcp stream. I am using this code to send.
byte[] bytes = ASCIIEncoding.ASCII.GetBytes("connect"); NetworkStream stream = client.GetStream(); StreamWriter writer = new StreamWriter(stream); writer.Write(bytes); writer.Close(); And this code to read:
public void getConnectionString() { NetworkStream ns = client.GetStream(); byte[] bytes = new byte[client.ReceiveBufferSize]; ns.Read(bytes, 0, bytes.Length); string info = Encoding.ASCII.GetString(bytes); MessageBox.Show(info); } But all this is returning is System: byte[]
Shouldn't it return the string? What am I doing wrong?