Search code examples
c#tcptcpclienttcplistener

c# TCP/IP client is connected to internet or not


can i get client is offline or online in new thread in server side ?

it's mean when a client connected to my server i want check in new thread that The client is still online or not .


Solution

  • It looks like you have the url incorrect for 'TcpClient', and you are not calling the 'Connect' method of the 'TcpClient' instance... here's the corrected version..see this here on MSDN....If I were you, I would wrap this up in a try/catch clause to see the exact error... nitpicky aside, if you are using disposable objects, wrap them up in a using clause also!