468,548 Members | 1,868 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,548 developers. It's quick & easy.

SocketServer class examples

Howdy group,
So I am in the middle of using the socketserver class from the std
library and have run into a problem that probably reveals my
misunderstanding of sockets. I have a class defined like so:

class tcp_listener(SocketServer.ThreadingTCPServer):
def __init__(self, addr, port):
SocketServer.ThreadingTCPServer.__init__(self, \
(addr, port), Daemon.request_handler)

""" Yes I realize the above is silly and redundant """

And a request handler in Daemon that has a handle function that works like
so:
def __req_handle(self, req):
""" Do stuff with req and return a response afterwards """
return response

def handle(self);
while True:
input = self.rfile.readline()
request = input
while input and not re.search('EOF$', input):
input = self.rfile.readline()
request += input

self.wfile.write(self.__req_handle(request))

The client end looks almost identical to the example in the python docs. So
the problem here is that this code doesn't work. Using tcpdump I can tell
that the client is sending to the server properly but the server is never
responding. Or when it tries to respond it gets stuck in the write. What's
going on here. I can't seem to find a single example of how to use this
class on the client and server side and I don't want to use twisted (because
I should understand how this works instead of relying on canned software).
Does anyone know where I can find an example of a functioning SocketServer
and client? Google seems to help nought here.
Thanks,
Fred

Jul 18 '05 #1
0 1171

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by lebo | last post: by
3 posts views Thread by Olivier Hoarau | last post: by
3 posts views Thread by Ergin Aytac | last post: by
reply views Thread by Adil Hasan | last post: by
12 posts views Thread by Paul Rubin | last post: by
4 posts views Thread by google | last post: by
12 posts views Thread by rbt | last post: by
reply views Thread by Tomi Hautakoski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.