Domanda

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.

È stato utile?

Soluzione

Answer is found. Seems that was simply my own mistake or this is how Pipes work in MQL - channel always needs to be Duplex so line in C# needs to be replaced with the following :

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

Parameter PipeDirection.InOut says pipe to be two-way.

P.S. Though it is a little weird anyway because conjunction C# Server <-> C# Client can work in both modes (In / Out or one of them)

Altri suggerimenti

Server: C# / Client: MetaTrader

I had two other problems:

  1. The client and server needed to be run as Administrator
  2. I needed to set buffer size for input and ouput (Default is zero => dynamically calculated => there was an error on this).
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top