Closed aymensmurf closed 4 years ago
So to my understanding you have to make a new socket for every client. am I understanding that right?
@aymensmurf, the socket is created automatically for every client. You just access it from the createServer()
callback.
It still a little vague, but I will have to look more into it. Thanks for your help.
I hope this example can help you!
const connectedSockets = []; // We store the connected sockets here
// Create the server
const server = TcpSocket.createServer((socket) => {
connectedSockets.push(socket); // Add the new connected socket
});
// Send a message to the first connected client
connectedSockets[0].write('Hello server');
Following the documentation: