New article MetaTrader 4 Expert Advisor exchanges information with the outside world has been published:
Author: Sergey Sartakov
Such effect is caused by the fact that practically any router performs the so called Network Address Translation (NAT). The network address is represented by the <protocol, IP, port> tuple. Any element of this tuple can be changed by router, it all depends on particular router model.
What you are actually talking about here is PAT Port Address Translation.
"Here is a software tool which provides MetaTrader 4 Expert Advisors with an ability of creating both server and clients. Clients can establish connections both with their own servers and with any other types of servers which provide peer-to-peer protocol connections."
Invalid translation - " peer-to-peer " ! Correct one is "point-to-point"
"In the next version of the article we will consider Peer-To-Peer (p2p) type of connection."
Have you got next version yet?
Dear Sergey Sartakov
I am trying to get your example(1.2.2. where the C++ program acts as an echo server, while expert advisor acts as a client for this C++ server) up running.
1. I have put the NetEventsProcDLL.dll in C:\Windows\System32 and also C:\Windows\SysWOW64 because I am using Window 7 64 bit. wihout putting the DLL at Syswow64 Folder, the echoserver.exe cant be run.
2. I have put the NetEventsProc.exe in "C:\NetEventsProc\" folder.
3. The echoserver.exe is successfully run. I check using CMD command netstat -a. it shows my computer ip (192.168.1.6) is listening at port 2000.
4. At the metatrader 4, I have put the ImportNetEventsProcDLL.mqh in the Include file
5. I have changed the ps8_ServerIP in the client.mq4 to 192.168.1.6 which is my local computer IP. and compile successfully.
6. after I attach it to the chart, and make sure the ALLOW Dll imports are checked as shown below.
7. After I run it, it still shows error as below. Please help
According to the WINSOCK, WSAENETURNREACH (10051) means Network is unreachable.A socket operation was attempted to an unreachable network. This usually means the local software knows no route to reach the remote host.
But i have make sure my ip is set correctly as shown above.
please advise, dear experts here.
Hi michaelt4268 !
The problem is NetEventsProcDLL.dll functions are designed to work with ANSI string but new MT4 works with UNICODE string.
For your separate example you should manage in such way:
For MT4 - correct:
// Only for Clients:
int ConnectTo(uchar& ps8_ServerIP, // in - string ps8_ServerIP = "0123456789123456"
int s32_Port, // in
int& ph_Client); // out - int ph_Client
2. Before call to ConnectTo(...)
make conversion UNICODE string to ANSI string:
and now you can connect to server -
s32_Error = ConnectTo(uc_ServerIP, s32_Port, ph_Client);
correct this line -
was - string GetErrMsg(int ps32_Error)
needed so - string GetErrMsg(uint ps32_Error)
You example should work after that, but other examples should be corrected this way too.
Besides include NetEventsProcDLL.dll functions defitnition c++ file must be corrected for another examples.