Tkinter/threading issue

Jerrad Genson jerradgenson at
Sun Aug 15 22:55:49 CEST 2010

class MessageServer:
    '''Creates a message server object that listens for textual
       and sends it back to the main program. Intended to be spawned
as a
       separate process.

    def __init__(self, port_number, server_send, server_receive):
        '''@param server_send The pipe MessageServer uses to send text
back to the main program.
           @param port_number The port the server listens on the
network at.

        self.server_send = server_send
        self.server_receive = server_receive
        self.client_socket = None
        self.address = None

        self.error_logger =

        self.server_socket = socket.socket(socket.AF_INET,
        self.server_socket.bind(('localhost', port_number))


    def listen(self):
        # listen for messages until process is killed
        # if a message is received, send it back to the main program
        (self.client_socket, self.address) =
        while True:
            input_stream = str(self.client_socket.recv(1024))
            if len(input_stream) != 0:
                os.write(self.server_send, input_stream)
                input_stream = None

More information about the Python-list mailing list