在 C# 中使用命名管道进行进程间通信PHP
在 C# 中使用命名管道进行进程间通信很容易,但我不确定如何在 php 中执行此操作,或者是否可能。所以我有这些问题:
- php 中可以使用命名管道吗?
- 是否可以有一个 C# 命名管道客户端连接到 php 命名管道服务器?
- 我到底要怎么编码呢? :)
对上述任何问题的回答都会如此有帮助..谢谢:)
编辑:它是一个独立的 php 程序,而不是基于网络的应用程序。
edit2:命名管道服务器可以在C#端,也可以在PHP端,这并不重要。我已经为两者制作了 C# 示例..但我不知道从哪里开始 php
Interprocess Communication using Named Pipes in C# is easy, but im not exactly sure how to do this in php, or if its even possible. so i have these questions:
- Is named pipes possible in php?
- Is it possible to have a C# named pipe client, connect to a php named pipe server?
- how the heck would i code that? :)
an answer to any of the above questions would be so helpful.. thanks :)
edit: Its a stand alone php program, not a web-based app.
edit2: The named pipe server can be in the C# side, or the PHP side, it doesnt matter. I have made C# examples for both.. but i dont know where to start for php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果它已经创建,那么您可以使用 PHP 的
fopen
函数将命名管道作为文件打开。在 Windows 中,管道“文件”路径看起来像“\\.\pipe\pipe_name”,但是有一个 开放问题 阻止了此操作。解决方法是使用计算机的名称而不是路径中的点:
虽然我投票支持 Tommy 推荐的套接字,但它们很简单,跨平台,并且如果需要的话还可以跨机器。
If it is already created then you can open a named pipe as a file using PHP's
fopen
function.In windows the pipe "file" path looks like "\\.\pipe\pipe_name", however there is an open issue in PHP which prevents this from working. The workaround is to use the computer's name instead of the dot in the path:
Though I vote for sockets like Tommy recommended, they're easy, cross-platform, and inter-machine if need be.
可以使用套接字吗?为什么它必须是管道?
看起来 PHP 有很多套接字:
https://www.php.net/sockets
流函数:
http://php.net/manual/en/ref.stream.php
你看到这个了吗?
PHP 和命名管道: http://my .opera.com/zomg/blog/2007/08/29/php-and-named-pipes
posix_mkfifo:
http://www.phpbuilder.com/manual/function.posix-mkfifo。 php
编辑 我假设你在 Windows (C#) 上,所以这可能不起作用......
Can you use sockets? Why does it have to be a pipe?
Looks like PHP has lots for sockets:
https://www.php.net/sockets
Stream Functions:
http://php.net/manual/en/ref.stream.php
Did you see this?
PHP and named pipes: http://my.opera.com/zomg/blog/2007/08/29/php-and-named-pipes
posix_mkfifo:
http://www.phpbuilder.com/manual/function.posix-mkfifo.php
EDIT I am assuming you are on windows (C#) so that may not work....