一些实现命名管道通信服务应用程序的来源或有关它的帮助
我正在实现我自己的命名管道客户端/服务器类,但我遇到了太多麻烦,而且互联网上没有太多信息。 我已经找到了很多使用管道但使用 vlc 应用程序的实现,但我正在使用服务应用程序。
我也接受有关如何使用管道的提示。
我的实际问题是: 虽然服务器应用程序只收到来自客户端的一条消息,但此后我的服务器无法再使用 PeekNamedPipe() 。 我从 GetLastError 收到的错误消息是“管道的另一端有一个进程”,但是......我不知道该怎么解决这个问题。 如果我关闭客户端应用程序,我收到的消息是“管道正在关闭”,此后我无法建立客户端通信。
tks
I'm implementing my own named pipe Client/Server class, but I'm getting too much troubles and no much information about on internet.
I already found a lot of implementation with pipes but with vlc application but I'm working with service applications.
I accept hints about how to work with pipes too.
My actual problem is:
While server the app just receive one message from the client, after this my server can't use PeekNamedPipe() any more.
My error message that I get from GetLastError is "there is a process on other end of the pipe", but.... I don't know what to solve do with this.
If I close the client app, the message I get is "The pipe is being closed", and I can't establish a client communication after this.
tks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
哦哦我发现问题了。
我正在阅读一些 Windows 文章,发现我必须使用 after peek 和 after disconnect 来连接到命名管道。这是有道理的。
ConnectNamedPipe(FPipeHandle, nil) 和 PeekNamedPipe(FPipeHandle, nil, 0, nil, @LBytesSize, nil) 之后
执行操作后我必须调用 DisconnectNamedPipe(FPipeHandle);
释放进程。
tks
Oooo I found the problem.
I was reading some windows articles and I found out that I must connect to the named pipe using after peek and after disconnect. It make sense.
ConnectNamedPipe(FPipeHandle, nil) and after PeekNamedPipe(FPipeHandle, nil, 0, nil, @LBytesSize, nil)
And after doing my operation I must call DisconnectNamedPipe(FPipeHandle);
To free the process.
tks
我认为在 Vista 或 7 中运行应用程序时会遇到一些麻烦。
在 XP 下,服务和客户端应用程序之间的通信没有问题。
但“感谢”Vista 和 7 引入的新 UAC 和安全策略,您需要设置一些安全参数。
请参阅我在开源框架的实施和测试过程中发现的内容。
您有一个命名管道客户端和服务器通信的工作示例,还使用作为服务运行的服务器进行了测试,在我们的源代码存储库中。
I think you'll get some troubles when running your application in Vista or Seven.
Under XP, no problem of communication between a service and a client application.
But "thanks" to the new UAC and security policy introduced with Vista and Seven, you need to set some security parameters.
See what I found out during implementation and testing of our Open Source framework.
You have a working example of Named Pipe client and server communication, also tested with the server running as a service, in our source code repository.
如果您有一些示例代码,请注意您需要在表单上创建的 GUI 组件:
发送方单元:
接收方单元:
希望这会有所帮助。
hier you have some sample code, notice the GUI components you will need to create on your form:
Sender unit:
Receiver unit:
hope this helps.