I am working on a system which uses C# applications and a socket to connect to remote devices, the connection is established by connecting to the IP address and a port number. A very short plain text message is sent and requests are issued again using a short text message.
The response is also plain text. I want to replace the applications that perform these transactions on the client side with node.js
In the node application I have installed socket.io and also socket.io-client modules, I am using node.js v21.7.1 on Windows 10 Pro version 10.0.19045
In my node application:
var socket = require("socket.io");
var socketcli = require("socket.io-client");
...
var strTestCli = "X.X.X.X:1024";
var sckTest = socketcli.connect(strTestCli);
console.dir(sckTest);
sckTest.on("connection", objConn => {
console.log("Connected to " + strTestCli);
objConn.on("disconnect", () => {
console.log("Connected to " + strTestCli + " disconnected!");
});
});
Obviously I have not put in the IP address, however I know the one I’m using is correct and exists.
When I dump out sckTest, the uri shows:
uri: 'undefined//X.X.X.X:1024'
...
engine: Socket {
...
hostname: 'undefined',
port: '80'
Am I completely going down the wrong route? Can anyone help put me on the right path, can this be done with node.js ?