How can a TcpClient
be pinged from a server in order to see its response time? I have a TCPServer
that I have created with a TCPClientManager
that I have also created. This simply adds a new Client
with a .NET TcpClient
property to aList
whenever a client connects. How can I get the address of the TcpClient
so that I can ping it using .NET Ping
?
public long PingClient(Client client)
{
long pingTime = 0;
Ping pingSender = new Ping();
// The class Client has a property tcpClient of type TcpClient
IPAddress address = IPAddress.Parse(Client.tcpClient...???);
PingReply reply = pingSender.Send(address);
if (reply.Status == IPStatus.Success)
{
pingTime = reply.RoundtripTime;
}
return pingTime;
}