1

I am trying to send some data via Named Pipes. I created Named Pipe Server in C# and client in MQL5 (it is just a C++ wrapper). Server works fine and can be reached from Named Pipe Client written in C# so communication C# <-> C# works fine. Also i tried utility PipeList and it also shows that my pipe server is visible and available.

The only problem is with client written in MQL5 (C++) - it does not find the path to the pipe server so communication MQL <-> C# is failing.

Could anybody suggest :

  • what am i doing wrong?
  • how to check that both C# and MQL are accessing the same physical path and the same location?

Server :

NamedPipeServerStream pipeStream = new NamedPipeServerStream("MQL5", PipeDirection.In, 1, PipeTransmissionMode.Byte) 

I also tried full path \\\\.\\pipe\\MQL5 with no success

Client :

CFilePipe iPipe;

while(IsStopped() == false)
{
    Print("This loop is infinite because there is no connection");
    if (iPipe.Open("\\\\.\\pipe\\MQL5", FILE_READ | FILE_WRITE | FILE_BIN) != INVALID_HANDLE) break;
    Sleep(250);
}

Thanks.

4

2 回答 2

1

找到答案了。似乎这只是我自己的错误,或者这就是管道在 MQL 中的工作方式 - 通道始终需要是双工的,因此 C# 中的行需要替换为以下内容:

NamedPipeServerStream pipeStream = new NamedPipeServerStream(name, PipeDirection.InOut, 1, PipeTransmissionMode.Byte)

参数管道方向。InOut表示管道是双向的。

PS 虽然这有点奇怪,因为结合 C# Server <-> C# Client 可以在两种模式下工作(输入/输出或其中一种)

于 2013-08-10T12:10:02.103 回答
1

服务器: C# /客户端: MetaTrader

我还有两个问题:

  1. 客户端和服务器需要以管理员身份运行
  2. 我需要为输入和输出设置缓冲区大小(默认为零 => 动态计算 => 出现错误)。
于 2017-02-01T20:00:05.077 回答