socket (multithread)

Steve Holden sholden at holdenweb.com
Mon Sep 18 18:39:58 CEST 2000


izam96 at hotmail.com wrote:
> 
> Hello
> 
> i have writing a simple python code that run as a server that using
> socket module. I would like to connect to the server from 2 or more
> client (multithread) so it can send data to the server and the server
> can respond back.I'm getting trouble to to that because when the
> first client had connected to the server the second client cannot
> send any information to the server and also cannot get respond from
> the server.
> 
Did you use the socketserver library?  In general, once a socket has an
active connection you need to run an active thread with that while some
other thread waits for new connections at the same address.

Don't forget a socket has two ends, and once those two ends are connected
nothing else can "break in" on the conversation.

> Is there any chat software(server/client) written in python??? or any
> example on socket programmming.

Take a look at the socketserver, SimpleHTTPserver and other library modules.
(although I seem to remember SimpleHTTPServer isn't programmed to handle
multiple concurrent service requests, it does at least discuss what you'd
need to do in practice).

regards
 Steve
-- 
Helping people meet their information needs with training and technology.
703 967 0887      sholden at bellatlantic.net      http://www.holdenweb.com/




More information about the Python-list mailing list