473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

named pipes on Windows

Hi all,

I'm trying to create a named pipe to communicate with another
application from a PHP application. The thing is that I cannot use any
of the posix functions on Windows, including posix_mkfifo.
Is there any other way to create a named pipe and if so.... how?
Thanks in advance.

Peter.
--
http://www.phpforums.nl
Oct 31 '06 #1
4 7992
rh

"Peter van Schie" <va************@gmail.comwrote in message
news:45***********************@news.wanadoo.nl...
Hi all,

I'm trying to create a named pipe to communicate with another
application from a PHP application. The thing is that I cannot use any
of the posix functions on Windows, including posix_mkfifo.
Is there any other way to create a named pipe and if so.... how?
Thanks in advance.

Peter.
Have you tried popen() or proc_open()?
Rich
Nov 2 '06 #2
"Peter van Schie" :vanschie.peter at gmail.com: asked:
: I'm trying to create a named pipe to communicate with another
: application from a PHP application. The thing is that I cannot use any
: of the posix functions on Windows, including posix_mkfifo.
: Is there any other way to create a named pipe and if so.... how?
: Thanks in advance.

I haven't messed with this but perhaps it's of some help. The VB
declarations to the API are as follows:

Public Declare Function CreatePipe Lib "kernel32.dll" ( _
ByRef phReadPipe As Long, _
ByRef phWritePipe As Long, _
ByRef lpPipeAttributes As SECURITY_ATTRIBUTES, _
ByVal nSize As Long) As Long

Public Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type

The same thing for MASM:

CreatePipe PROTO :DWORD,:DWORD,:SECURITY_ATTRIBUTES,:DWORD
SECURITY_ATTRIBUTES STRUCT
nLength DWORD ?
lpSecurityDescriptor DWORD ?
bInheritHandle DWORD ?
SECURITY_ATTRIBUTES ENDS

And for C#:

[DllImport("kernel32.dll")]
public static extern int CreatePipe (
int phReadPipe,
int phWritePipe,
ref SECURITY_ATTRIBUTES lpPipeAttributes,
int nSize);
[StructLayout(LayoutKind.Sequential)]
public struct SECURITY_ATTRIBUTES{
internal int nLength;
internal int lpSecurityDescriptor;
internal int bInheritHandle;
}

Perhaps someone here can provide an example of how to set up
such API calls inside of PHP and provide an example in this case?

Jim Carlock
Post replies to this newsgroup.
--
Ask The North Carolina Swimming Pool Design Expert
for pricing and details in getting a Sporting Swimming Pool built
in North Carolina.
http://www.aquaticcreationsnc.com/sw...der/nc/ask.php
Nov 2 '06 #3
Jim Carlock schreef:
"Peter van Schie" :vanschie.peter at gmail.com: asked:
: I'm trying to create a named pipe to communicate with another
: application from a PHP application. The thing is that I cannot use any
: of the posix functions on Windows, including posix_mkfifo.
: Is there any other way to create a named pipe and if so.... how?
: Thanks in advance.

I haven't messed with this but perhaps it's of some help. The VB
declarations to the API are as follows:
[snip]

Perhaps someone here can provide an example of how to set up
such API calls inside of PHP and provide an example in this case?
Hi Jim and Rich,

Thank you both for your replies. I actually tried using Jim's approach
by using the W32api extension
(http://nl2.php.net/manual/en/ref.w32api.php). However it turned out
that the extension has been removed from the PECL repository.

I just tried Rich's suggestion, using popen() and that actually works.
So thanks a lot I got it working now. :)

Regards,
Peter.
--
http://www.phpforums.nl
Nov 3 '06 #4
Peter van Schie schreef:
Jim Carlock schreef:
>"Peter van Schie" :vanschie.peter at gmail.com: asked:
: I'm trying to create a named pipe to communicate with another
: application from a PHP application. The thing is that I cannot use any
: of the posix functions on Windows, including posix_mkfifo.
: Is there any other way to create a named pipe and if so.... how?
: Thanks in advance.
Here's an update for this issue, because I found the solution and it
might be useful to other people in the future.
popen() returned true, but that didn't mean it worked. As the php docs
state: "If the command to be executed could not be found, a valid
resource is returned. This may seem odd, but makes sense; it allows you
to access any error message returned by the shell".

I then walked into this bug report: http://bugs.php.net/bug.php?id=29005
The bug report states that the dot in a filepath is being interpreted as
"current directory" by php. This is still true in the current stable PHP
version 5.2 and even in the latest PHP 6 snapshot.
So a named pipe path such as: "\\.\pipe\mypipe" is being crippled by
PHP's fopen.
Therefore a logical workaround is this: using fopen with the machine
name like this works:

<?php
$strComputername = php_uname('n');

$resPipe = fopen("\\\\" . $strComputername . "\\pipe\\mypipe", "w");

if ($resPipe === false)
{
echo 'Failure';
}
else
{
echo 'Success';
fwrite($resPipe, "foo");

fclose($resPipe);
}
?>

I hope this is useful to someone in the future. :)

Regards,
Peter.
--
http://www.phpforums.nl
Nov 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Matt W | last post by:
Hi all, I just noticed this in the manual yesterday: http://www.mysql.com/doc/en/Windows_running.html "MySQL supports TCP/IP on all Windows platforms. The mysqld-nt and mysql-max-nt servers...
0
by: piyush | last post by:
Sorry for repeated posting but I couldnt get things right/completely in the first post. I am in the process of deciding the IPC mechanisms to use for communication between 1) An application...
5
by: rajnish | last post by:
Hi Gurus, I am a newbee in C++ field. And I have been assigned to complete a task of create a template class, so that names pipes can be created using this template. I don't have a clue from...
5
by: glenn.owens | last post by:
In the process of doing some routine monitoring/clean-up we've discovered that several (many?) users are apparently set to access our SQL Server 2000 database instances via the Named Pipes...
2
by: Rudolf Bargholz | last post by:
Hi, DB2 7.1 FP11 Windows 2000 Earlier this evening, after dropping and recreating a trigger, DB2 locked up. I am not entirely sure that the cause of the problem was the replacing of the...
4
by: Ken Allen | last post by:
Is there any built-in facility for handling named pipes in C#/.Net, or must one use unsafe code to access the WIN32 API directly? There exists some code that uses named pipes heavily and there...
0
by: piyush | last post by:
Sorry for repeated posts, I couldnt get things right and complete in the previous post. I am in the process of deciding the IPC mechanisms to use for communication between 1) An application...
1
by: motimh | last post by:
I am trying to use named pipes to interprocess communication. My concern is the cpu wait time between them. Can someone show me the code to do this in VBNet? Is there an event that can be...
1
by: dgk | last post by:
I trying to use a named pipe but can't figure out how to get the callback to work: Module Module1 Private ps As System.IO.Pipes.NamedPipeServerStream Public Sub main()...
2
by: simkar | last post by:
Error: provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server SqlException (0x80131904) General Info: Application is on server1(outside the firewall)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.