Re: A beginner's question on thread

From: Josiah Carlson (jcarlson_at_uci.edu)
Date: 04/07/04


Date: Tue, 06 Apr 2004 21:54:56 -0700

Timothy Wu wrote:

> I'm writing a small utility that listens for socket connections, and
> also repond to user inputs via a text menu selection.
>
> In order to respond to both the user and the incoming connections I
> figure I need to use thread.
>
> I think I would use the main thread to handle the menu and spawn a
> thread which listens on a socket.
>
> Now my question is, how do I terminate the server thread if user wants
> to exit the application? If the server just sit there and listen the
> thread would never terminate by itself. What kind of inter-thread
> communications are available and where would I find info/tutorial on that?

No need for threads.

If you have your server set up properly with asyncore, the below link
will give you an example using wxPython that will just work...

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&safe=off&threadm=c35daa%24ka7%241%40news.service.uci.edu&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DISO-8859-1%26safe%3Doff%26c2coff%3D1%26q%3Djosiah%2Bsocket%2Bwxpython%26btnG%3DSearch%26meta%3Dgroup%253Dcomp.lang.python.*

Enjoy.

  - Josiah



Relevant Pages

  • Re: netcat vs nc vs alternative network read/write utility
    ... >> Creating a server that listens for incoming connections isn't much ... that's about as simple as it gets for a non-forking server.. ... Tony Lawrence ...
    (comp.unix.sco.misc)
  • Re: Seti-like program
    ... All you realy need is a server with a GUI that listens all the time for ... and a client that will connect to the server and work in the ... - Figure out what action you want the client to do. ...
    (comp.lang.python)
  • Re: Allow non-Administrator to view and terminate processes for all users
    ... that is a classic client server implementation. ... tight CPU loop - no page faults, no I/O, no database interaction, no network ... track down and terminate the "bad" processes. ...
    (microsoft.public.windows.server.security)
  • Re: PDA as "X terminal"
    ... obviously not using XDMCP, etc. -- OTOH, that would make life ... I've never used "terminal services" (there is a TS client built ... It pushes most of the work onto the application server; ... any connected clients will typically terminate. ...
    (comp.arch.embedded)
  • Re: Servers automatically getting renamed!!!
    ... "Old programmers never die. ... They just terminate and stay resident." ... One job to launch this command each time the server starts: ...
    (microsoft.public.win2000.general)