0

I want to determine the ping of a socket.io server without actually creating a socket. Why? Because I have a bunch of socket.io servers, and I want the client to connect to the one with the lowest latency and I don't want to manage all those sockets. Plus i think creating a socket and closing it on every single server just for a simple ping does not make sense and would cause performance problems.

Ideally, the client would create a websocket just for each ping (i think i know how to do that). But on the server side, what is the best way to receive those websocket messages (made with ws://), since you don't typically make/receive direct ws requests with socket.io (as all of that stuff is handled under-the-hood)?

Chris Scott
  • 583
  • 1
  • 7
  • 23

1 Answers1

-3

Use the ping class.

Ping ping = new Ping();        
PingReply reply= ping.Send("www.google.com");
Console.WriteLine(reply.RoundtripTime.ToString() + "ms");

As done here, too: Making a "ping" inside of my C# application

pookie
  • 3,796
  • 6
  • 49
  • 105
  • 1
    um, I'm on node.js/socket.io which means javascript only. :) – Chris Scott Jul 22 '17 at 18:01
  • Apologies. I had searched for questions related to c#, and for some reason your question was show. Does this question help? https://stackoverflow.com/q/4071258/596841 – pookie Jul 22 '17 at 20:18