Hi all,

I am just a newbie and was looking at a simple client server
program. Derived from the TCPServer class in (SocketServer module). I am
on version 1.5.2.

My question is that in order to construct a TCPServer module i have
to pass it in a class derived from BaseRequestHandler class. I have to
override the handle method.
The code follows below.
class mine(BaseRequestHandler):
... def handle(self):
... print self.request, self.client_address,
... data = self.request.recv(300)
... while data:
... print data, len(data)
... data = self.request.recv(300)
... print "Done"
server_address = ('', 22222)
kk = TCPServer(server_address, mine)
The code works fine. But it took me a while to figure out how to
print the data. I had to look at other code just to know that
self.request is a socket type and do a type(socket) on it to get to the
functions that are available to me. What strategy are you people using
to determine the type of the object. It does affect my readability since
the i had to plug in dir(self.request) in the code to make sure the type
is a socket.


Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
postedDec 14, '01 at 10:52p
activeDec 14, '01 at 10:52p

1 user in discussion

Saurabh Chadha: 1 post



site design / logo © 2022 Grokbase