Need help with socket server code
chris liechti
cliechti at mails.ch
Sat Jul 14 14:46:41 EDT 2001
i can not see how printing the same list over and over again when no data
arrives.... but i think you are looking for
s.setblocking(0)
where s is your socket object.
keep in mind that this will print the list relatively fast and you will get
100% CPU usage.
as an other poster mentioned: if you want to do two or more things at the
same time - use threads (module threading).
then you can run your (blocking) communications stuff in a separate thread.
chris <cliechti at mails.ch>
"Shane Anglin" <shane.anglin at mtni.net> wrote in
news:mailman.995132124.31082.python-list at python.org:
> Here's the basics of what I want to do with my new app:
> Main loop is:
> 1 - check socket for any incoming data
> 1a - if no data on socket, go to 2, else get the data and place it into
> a list 2 - print out list
> 3 - go to 1 and do it all over again
>
> Currently, I can create a TCP socket server app using examples that
> will sit and wait (idle 99% of the time) and accepts the incoming data
> just fine, my 'print list' part is not processing at all until I get
> any new data in... for example, 1-wait on a client connect on socket,
> when a connection happens, get data, 2- place new data into list, print
> list, 3 -go to 1 and do it all over again... in this scenario, #1 has
> the rest of my code 'hostage' until a client connection is made and
> closed.
>
> Thanks a bunch!
> Shane Anglin
> shaneanglin at bigfoot.com
>
More information about the Python-list
mailing list