Need help with socket server code

Donn Cave donn at u.washington.edu
Mon Jul 16 18:05:51 CEST 2001


Quoth "Shane Anglin" <shane.anglin at mtni.net>:
| 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. 

The select() will check for events on a set of sockets or other selectable
devices, with an optional timeout.

  while 1:
      rl, wl, el = select.select([s], [], [], 10.0)    # 1
      for r in rl:
          if r is s:
              # 2 ...

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list