我正在尝试在.NET中实现命名管道服务器.客户端将是C++.发送的数据的性质与问题无关.
我的第一个天真实现看起来像:
using (NamedPipeServerStream stream =
new NamedPipeServerStream(PipeName,
PipeDirection.InOut,
numberOfListeners,
PipeTransmissionMode.Message))
{
while (true)
{
try
{
stream.WaitForConnection();
var request = ReadRequest(stream);
var reply = Process(request);
WriteReply(stream, reply);
stream.WaitForPipeDrain();
}
catch (Exception ex)
{
//TO DO: log
}
}
}
Run Code Online (Sandbox Code Playgroud)
我接近这个吗?
当两个客户端同时打开连接时会发生什么?
他们会共享相同的流,数据会混合在一起吗?
我怎么能避免这个?
任何有关此想法或资源都会有所帮助.我对这个话题很陌生.
| 归档时间: |
|
| 查看次数: |
10863 次 |
| 最近记录: |