TcpListener : Best approach to check the active connections
-
hello, I have programed a MultiThreaded TCP server using TcpListener, TcpClient and NetworkStream. What can be the best approach to check the active connections and close the inactive ones? I am looking for some way so that when client closes the connection only then the connection closes, regardless if the comunication has taken place or not for a long time. Is there any way? Zishan
-
hello, I have programed a MultiThreaded TCP server using TcpListener, TcpClient and NetworkStream. What can be the best approach to check the active connections and close the inactive ones? I am looking for some way so that when client closes the connection only then the connection closes, regardless if the comunication has taken place or not for a long time. Is there any way? Zishan
Set the SendTimeout and ReceiveTimeout on the classes and the framework will do this for you :) Yes, even I am blogging now!
-
Set the SendTimeout and ReceiveTimeout on the classes and the framework will do this for you :) Yes, even I am blogging now!
Actually I have an array of TcpClient and equal number of Threads for each client at the server. I have another thread (connectionDestructorThread) that is checking all these clients. If any client disconnects, this connectionDestructorThread should get the notification and aborts that client's Thread and free up resources. I don't see how SendTimeout and ReceiveTimeout can help in this senario. regards, Zishan
-
Actually I have an array of TcpClient and equal number of Threads for each client at the server. I have another thread (connectionDestructorThread) that is checking all these clients. If any client disconnects, this connectionDestructorThread should get the notification and aborts that client's Thread and free up resources. I don't see how SendTimeout and ReceiveTimeout can help in this senario. regards, Zishan
Yes I did it!!! Thanks for the help. :-) Best Regards, Zishan