anyone have a simple example of websocket worked

 

Hi guys i try to use a websocket  for exchange data mt5  to my program i use this code for do that 

//+------------------------------------------------------------------+
//|                        TCP_Send_Test.mq5                        |
//+------------------------------------------------------------------+
#property strict

string Address = "127.0.0.1";
int Port = 5001;

int socket_handle = INVALID_HANDLE;
datetime last_send_time = 0;

//+------------------------------------------------------------------+
int OnInit()
{
    socket_handle = SocketCreate();
    if (socket_handle == INVALID_HANDLE)
    {
        Print("Errore creazione socket: ", GetLastError());
        return INIT_FAILED;
    }

    Print("EA inizializzato");
    return INIT_SUCCEEDED;
}

//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
    if (socket_handle != INVALID_HANDLE)
        SocketClose(socket_handle);

    Print("EA terminato");
}

//+------------------------------------------------------------------+
void OnTick()
{
    if (TimeCurrent() - last_send_time >= 1) // ogni secondo
    {
        last_send_time = TimeCurrent();

        if (SocketConnect(socket_handle, Address, Port, 5000))
        {
            string messaggio = "Test da MT5 alle " + TimeToString(TimeCurrent(), TIME_SECONDS) + "\n";
            uchar data[];
            int len = StringToCharArray(messaggio, data);

            if (SocketSend(socket_handle, data, len) == len)
                Print("Messaggio inviato: ", messaggio);
            else
                Print("Errore invio: ", GetLastError());

            SocketClose(socket_handle);
        }
        else
        {
            Print("Errore connessione: ", GetLastError());
        }
    }
}

for testing if work good i open a netcat ( nc64.exe -l -p 5001)  before run EA , i tryed also with a server http in python but nothing  return me error connection  4014 ,i able  also a port and ip in mt5 options

but  nothing  anyone  have  a simple example real worked ?  or tutorial  step by step ? i look this  https://www.mql5.com/en/articles/5691;   but not work for me , the code return 2  error and after fix them i have the same problem ,i find in documentation but  i have only 

MetaTrader 5 and Python integration: receiving and sending data
MetaTrader 5 and Python integration: receiving and sending data
  • 2019.03.28
  • www.mql5.com
Comprehensive data processing requires extensive tools and is often beyond the sandbox of one single application. Specialized programming languages are used for processing and analyzing data, statistics and machine learning. One of the leading programming languages for data processing is Python. The article provides a description of how to connect MetaTrader 5 and Python using sockets, as well as how to receive quotes via the terminal API.
 
Hello sir, have you tried the code in project ? 
MQL5 Book: Advanced language tools / Projects / WebSocket protocol in MQL5
MQL5 Book: Advanced language tools / Projects / WebSocket protocol in MQL5
  • www.mql5.com
We have previously looked at Theoretical foundations of the WebSockets protocol . The complete specification is quite extensive, and a detailed...
 
i find a  solution,( not ask my why ?)  if you use websocket  with dll , you must specify a port  127.0.0.1:5001 , but  if  you use  a library  inside  of metatrader  you must use  127.0.0.1 , without port in this mode  work thanks at all for support o_O