我在TCP服务器\客户端遇到问题我在.NET 3.5(C#)中编写.
每当我使用下面的代码传输数据时,只有5个字符传输到服务器.如何修复我的代码,以便我传输超过5个字符?
TcpClient client = new TcpClient(connectto.ToString(), portto); Stream s = client.GetStream(); StreamReader sr = new StreamReader(s); StreamWriter sw = new StreamWriter(s); Byte[] data = new Byte[256]; data = System.Text.Encoding.ASCII.GetBytes("auth:" + adminPASS.Text); s.Write(data, 0, data.Length); data = new Byte[256]; String responseData = String.Empty; Int32 bytes = s.Read(data, 0, data.Length); responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
服务器只获取传输的前5个字符.其余的都丢失了.