Home » U++ Library support » U++ MT-multithreading and servers » how to stop a thread that is waiting, e.g., listen()
Re: how to stop a thread that is waiting, e.g., listen() [message #11837 is a reply to message #11802] |
Thu, 27 September 2007 13:43   |
 |
tvanriper
Messages: 85 Registered: September 2007 Location: Germantown, MD, USA
|
Member |
|
|
Out of my own curiosity, I took a peek at Thread.h/Thread.cpp in Core, and socket.h/socket.cpp in Web.
Thread.h/.cpp detail the Thread class, a class you can use for handling multi-threaded needs in an application. It exposes a Wait function, which returns an int. The integer it returns is either the exit code for the thread, or a numeric identifier for an event that was sent to the thread (well... in Windows... in POSIX, it seems to work differently, if I am reading this correctly... pthread_join [which will return 0] or the return value of the terminated thread).
For Windows, the Socket class seems to support the use of the Event object, but that object is not exposed to POSIX, if I'm reading everything correctly.
At a guess, you could probably create a Socket, set it up for networking however you need to, and use the static 'Wait' command with a timeout to wait on network traffic. If there's traffic, do what you need to do with the traffic. Otherwise, check a variable shared between your threads to see if you need to shut down your thread.
Perhaps someone else might have a better way to do this, but this seems to be the safest way to handle Sockets, multi-threading, and keeping your application working in both Windows and POSIX environments.
|
|
|
 |
 |
how to stop a thread that is waiting, e.g., listen()
By: bonami on Wed, 26 September 2007 11:40
|
 |
|
Re: how to stop a thread that is waiting, e.g., listen()
By: tvanriper on Wed, 26 September 2007 13:05
|
 |
|
Re: how to stop a thread that is waiting, e.g., listen()
By: bonami on Thu, 27 September 2007 10:57
|
 |
|
Re: how to stop a thread that is waiting, e.g., listen()
By: tvanriper on Thu, 27 September 2007 13:20
|
 |
|
Re: how to stop a thread that is waiting, e.g., listen()
By: tvanriper on Thu, 27 September 2007 13:43
|
 |
|
Re: how to stop a thread that is waiting, e.g., listen()
By: bonami on Fri, 28 September 2007 05:13
|
 |
|
Re: how to stop a thread that is waiting, e.g., listen()
By: tvanriper on Sat, 29 September 2007 14:46
|
 |
 |
Re: how to stop a thread that is waiting, e.g., listen()
By: bonami on Tue, 16 October 2007 11:59
|
 |
|
Re: how to stop a thread that is waiting, e.g., listen()
By: mirek on Wed, 17 October 2007 19:16
|
 |
 |
Re: how to stop a thread that is waiting, e.g., listen()
By: bonami on Fri, 19 October 2007 11:52
|
 |
|
Re: how to stop a thread that is waiting, e.g., listen()
|
 |
|
Re: how to stop a thread that is waiting, e.g., listen()
By: bonami on Mon, 22 October 2007 11:47
|
 |
|
Re: how to stop a thread that is waiting, e.g., listen()
|
 |
 |
Re: how to stop a thread that is waiting, e.g., listen()
By: bonami on Wed, 24 October 2007 04:20
|
 |
|
Re: how to stop a thread that is waiting, e.g., listen()
By: mirek on Sun, 11 November 2007 18:49
|
 |
|
Re: how to stop a thread that is waiting, e.g., listen()
By: bonami on Mon, 12 November 2007 02:19
|
Goto Forum:
Current Time: Tue Sep 02 10:15:12 CEST 2025
Total time taken to generate the page: 0.00796 seconds
|