Sockets and marshalling question

redhouse at my-deja.com redhouse at my-deja.com
Mon Jan 22 18:14:18 EST 2001


Hi-

  I'm trying to uses marshalling an sockets and my server is hanging.
Does anybody out there have an example of how to do this?

  The marshal.load() method is hanging. I have tested the same code with
fixed length strings, and it works. I have tested marshalling the
objects with dumps() and loads() and that works, too.

  So my question is if it is OK to use marshalling to avoid counting the
message bytes,sending the counter, etc.

Thanks-
  Carter

  Here's my server code:

class My_handler(SocketServer.StreamRequestHandler):
    def handle(self):
        """\
        Handler method
        Currently supports only one user at a time.
        """
        while 1:
            my_string=marshal.load(self.rfile)

class My_server:
    def __init__(self,listener_port):
        # Create an instance of our server class
        server=SocketServer.TCPServer( ('', listener_port), My_handler)

        # Enter an infinite loop, waiting for requests and then
servicing them.
        server.serve_forever()


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



More information about the Python-list mailing list