Reputation: 145
I am able to connect a web based app to a socket.io server, but not a terminal based app, this is what i use to connect to the socket.io server:
var socket = require('socket.io')
var connection = socket.connect('http://127.0.0.1:8080');
I get the following error:
TypeError: socket.connect is not a function
How can I connect a terminal app to a socket.io server, written in node.js
Upvotes: 1
Views: 1058
Reputation: 17508
The socket.io
is for creating WebSocket server. You can't use this module as a client. Instead try socket.io-client
var socket = require('socket.io-client')('http://127.0.0.1:8080');
socket.on('connect', function(){});
socket.on('event', function(data){});
socket.on('disconnect', function(){});
Upvotes: 2