我正在尝试使用端口 2628 连接到 dict.org 服务器,但无法从服务器获得完整响应。代码如下所示:
TcpClient client = new TcpClient("216.18.20.172", 2628);
try
{
Stream s = client.GetStream();
StreamReader sr = new StreamReader(s);
StreamWriter sw = new StreamWriter(s);
sw.AutoFlush = true;
Console.WriteLine(sr.ReadLine());
while (true)
{
Console.Write("Word: ");
string msg = Console.ReadLine();
sw.WriteLine("D wn {0}", msg);
if (msg == "") break;
Console.WriteLine(sr.ReadLine());
}
s.Close();
}
finally
{
client.Close();
Console.ReadLine();
}
当我为这个词输入“hello”时,它只会得到 1 行响应,然后如果我输入任何内容并按 enter,它将显示下一行,依此类推。如何一次显示完整的响应?