Solved

Server thread manupulation

Posted on 2004-04-28
3
168 Views
Last Modified: 2010-04-15
I m writing up a time server which communicates with clients via TCP/IP asynchronously.The listener itself runs on a thread spawned during initialisation. It listens on host at specified port for incoming connections and each client is served on a separate individual thread(i.e asynch op). The GUI allows the user to disconnect clients at any given time, and the way i do this is by closing all open connections, then closing the listening socket and finally aborting the thread the server is running on. Afterwards, I spawn a fresh thread to restart the server process. When i kill the thread, i do get exceptions thrown by the events that are already setup for the connected clients, but they are caught inside the code. Is this a good way of addressing the problem, are there standard/better ways of dealing with such a scenario?
would there be any examples i could refer to?
0
Comment
Question by:Code_mechanic
3 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 25 total points
ID: 10940565
you set a flag for shutdown ... give threads some period of time (reasonable lets say 15 seconds) to finish their current operations if they all havnt finished and gone to the lan of the dead at this point you start killing them.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question