Reputation: 1641
My nodejs / express server.js file:
const express = require('express');
const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);
const path = require('path');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const zmq = require('zeromq');
const sock = zmq.socket('pull');
const port = 3000;
sock.connect('tcp://127.0.0.1:3000');
console.log('Worker connected to port 3000');
sock.on('message', function(msg){
console.log('work: %s', msg.toString());
});
http.listen(port, () => {
console.log(`listening on ${port}`);
});
What do I need to do in order to send forex rates to tcp://127.0.0.1:3000
from MetaTrader Terminal, which is running locally in parallel with the nodejs application?
Basically I want to emit them using a socket.io to the clients.
Upvotes: 0
Views: 1119
Reputation: 387
In your expert, I think something like this will work. Haven't tried it.
#include <zmq_bind.mqh>
int client,server,context;
int init()
{
return(0);
}
int deinit()
{
z_close(client);
z_close(server);
z_term(context);
return(0);
}
int start()
{
Print("using zeromq version "+z_version_string());
context = z_init(1);
client = z_socket(context,ZMQ_REQ); //server: receives first
server = z_socket(context,ZMQ_REP); //client: sends first
if(z_bind(server,"tcp://127.0.0.1:3000")==-1) {
return(-1);
}
if (z_connect(client,"tcp://127.0.0.1:3000")==-1) {
return(-1);
}
z_send(client,"Hello world");
Print("message received is " +z_recv(server));
return(0);
}
I'm curious to know how you plan to decode the buffer sent from MT4. I can't get node.js to read the correct encoding.
var net = require('net');
var server = net.createServer(function (socket) {
socket.on('data', function (data) {
socket.write('Echo server\r\n');
});
});
server.listen(3000, '127.0.0.1');
Upvotes: 1