Answer the question
In order to leave comments, you need to log in
How to write in Named Pipe in Perl?
There is a program written in c ++, it is a pipe server, the following code is executed in it:
HANDLE hPipe;
char buffer[1024];
DWORD dwRead;
String out = "";
hPipe = CreateNamedPipe(TEXT("\\\\.\\pipe\\mypipe"), PIPE_ACCESS_DUPLEX | PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
PIPE_WAIT,
1,
1024 * 16,
1024 * 16,
NMPWAIT_USE_DEFAULT_WAIT,
NULL);
while (hPipe != INVALID_HANDLE_VALUE)
{
if (ConnectNamedPipe(hPipe, NULL) != FALSE) // wait for someone to connect to the pipe
{
out = "";
while (ReadFile(hPipe, buffer, sizeof(buffer) - 1, &dwRead, NULL) != FALSE)
{
buffer[dwRead] = '\0';
out += buffer;
}
}
WriteLog(0,"PIPE",out); //Этот код выводит на экран значение переменной out
DisconnectNamedPipe(hPipe);
}
sysopen(FIFO, "\\\\.\\pipe\\mypipe", O_WRONLY) or die "Couldn't open for writing: $!\n";
print FIFO "Hello world" or die "error print";
close FIFO;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question