Friday, July 10, 2015

Communication Between NodeJS Client and Matlab Server with Socket(TCP/IP)

Checkout Source Code


Run Matlab Server in one Terminal

$matlab -nodisplay

host='localhost';
port=5000;
s = server(host, port);
s.receive();
s.send('This is MatLab');
s.send('This is MatLab');

This is NodeJS
This is NodeJS
This is NodeJS

Run NodeJS client in another Terminal

$node

client = require('./client');
host='localhost';
port=5000;
c = new client(host, port);
c.receive();

This is MatLab
This is MatLab

c.send('This is NodeJS\n');
c.send('This is NodeJS\n');
c.send('This is NodeJS\n');