javascript - How do I send message to specific client in node.js -


how can send message specific client ?,is possible can send message specific client in node.js ?

var net = require('net');  var clients = [];  var server = net.createserver(function (socket) {     clients.push(socket);     var message = "message client";      //here how send specific client ?     }); 

thank in advance.

it's not entirely clear you're trying do, keeping list of sockets in clients array need apply whatever logic fits need select 1 of sockets , use .write() write data on socket:

var net = require('net'); var clients = []; var server = net.createserver(function (socket) {    clients.push(socket);    var message = "message client";     // pick socket array using whatever logic want , send    clients[0].write(msg); }); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -