Tcp client with socket.io (nodejs)

I need a nodejs server connected to a C # application, I don't like using third-party libraries, so I'm trying to use TcpClient, the server looks something like this:

var io = require('socket.io').listen(8000);
io.socket.on('connection',function(socket)
{
 console.log("connected");
}

and in a C # project:

var client = new TcpClient(Server,8000);
Socket s = client.Client;
if (!s.Connected)
{
   s.SetSocketOption(SocketOptionLevel.Socket,
   SocketOptionName.ReceiveBuffer, 16384);
   MessageBox.Show("disconnected");
}
else
{
   MessageBox.Show("connected");
   s.Send(Encoding.UTF8.GetBytes("something"));
}

for what i understood in "something", i have to write something that will call "on (" connection ") on the nodejs side, am i missing something?

PS: if you know a good third-party library for what I need, you can mention it

+5
source share
1 answer

Actually, the on ('connection') server should be triggered when the TcpClient object is created, because this happens when connecting, and not at the point where you are trying to send some data.

0
source

All Articles