Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interprocess Communication using Named Pipes in 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:

  1. Is named pipes possible in php?
  2. Is it possible to have a C# named pipe client, connect to a php named pipe server?
  3. 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

like image 990
caesay Avatar asked Sep 02 '10 01:09

caesay


Video Answer


1 Answers

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:

$name = php_uname('n');
$pipe = fopen("\\\\" . $strComputername . "\\pipe\\pipe_name", "r+");

Though I vote for sockets like Tommy recommended, they're easy, cross-platform, and inter-machine if need be.

like image 172
joshperry Avatar answered Sep 23 '22 02:09

joshperry