[as you'll see, I don't understand the basic concepts of a TCP server and client very well and probably socket.emit is not even possible, but I'd like to know the best alternative or similar thing...]
Socket.io has a beautiful thing to emit events and catch them on the other side, it's in it's first page (http://socket.io). Can I do something similar like that but with NodeJS' regular 'net' module ? If not then what's the equivalent ?
I tried:
server.js
var server = net.createServer(function(socket) {
socket.on("connect",function() {
socket.emit('test',{msg : 'did you get it ?'});
});
}).listen(8000);
client.js
var client = net.createConnection(8000, localhost);
client.on('connect',function(){
client.on('test',function(data) {
console.log(data.toString());
});
});
But as you can imagine, it does not work. How can I achieve this ?
Thanks in advance.