sockets: client dies...

Keith Murphy kpmurphy at my-deja.com
Thu Jan 25 11:12:16 EST 2001


ok here's what i understand.

 makes the conn.recv(1024) statement wait for a result, where as
conn.setblocking(0) just throws an exception if there isn't something
there immediately.

in my server, it's continuously listening for new clients on one thread,
and listening to current clients on another thread.  in the current
client thread:

            for u in userlist:
                try:
                    data = ''
                    data = string.strip(u.conn.recv(1024))

                    #
                    # all commands start with a /
                    if data[0] == '/':
                        server_msg, client_msg = u.do(data)

                        self.update_kill()

                        #
                        # tell the client stuff
                        if client_msg:
                            u.conn.send(client_msg)

                        self.disp(server_msg)
                except:
                    pass

...it checks to see if each client has something to say.  if not, it
throws the exception, and moves on.  if so, it executes their commands,
and displays results, etc.

is this a lame way to do this?  is there a better way?  i need to be
able to detect when a client has died.  currently this isn't possible,
or is it?

thanks gang,
keith


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list