当使用 .net NamedPipeClientStream类从 NamedPipes 服务器读取数据时,我只能在 C++ 中第一次读取时获取数据,每次它只是一个空字符串。在 c# 中,它每次都有效。
pipeClient = gcnew NamedPipeClientStream(".", "Server_OUT", PipeDirection::In);
try
{
pipeClient->Connect();
}
catch(TimeoutException^ e)
{
// swallow
}
StreamReader^ sr = gcnew StreamReader(pipeClient);
String^ temp;
while (temp = sr->ReadLine())
{
// = sr->ReadLine();
Console::WriteLine("Received from server: {0}", temp);
}
sr->Close();