[FRPythoneers] Cannot Get SocketServer to Work

Mike Romberg mike.romberg at noaa.gov
Wed Sep 17 11:39:59 MDT 2003


>>>>> " " == Dhruva B Reddy <bdhruva at gmx.net> writes:

     > I'm trying to write a simple socket server and client, using
     > SocketServer.  I use TCPServer, and my request handler
     > subclasses StreamRequestHandler.

     > The server hangs when it tries to read the request.  The call
     > to rfile.read() does not return until the client is killed.

     > Can someone tell me what I might be doing wrong?

  I'm pretty sure read() will read until it hits EOF.  With a socket,
you won't get an end of file until the socket is closed.  So, your
program is working as it should :).  You probably will want to send
the length of the string from the client before you send the string
itself.  This way your server knows how long the string should be.
You might also want to take a look at the xdr module.  It has methods
which can bundle up things like strings so they work better over a
socket.

Mike Romberg (mike.romberg at noaa.gov)



More information about the FRPythoneers mailing list