473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1296

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: lebo | last post by:
So I'm new to this python stuff - and this has me stumped # server import SocketServer PORT = 8037 class myRequestHandler(SocketServer.StreamRequestHandler): def handle(self): self.input...
3
by: Olivier Hoarau | last post by:
Hello, I have build a client/server application with the socket module. The server mades UDP broadcasting and the client only reads UDP broadcast messages. All work fine. Now I want to use for...
3
by: Ergin Aytac | last post by:
I'm trying to run a script written in python and have some socket connection problems. I cutted the origin script (more than 1000 lines) so it is only the part of the connection and there is no...
0
by: Adil Hasan | last post by:
Hello Fred, I just ran across your question. I think that the following code will work: ----- SERVER CODE ------ import SocketServer import time class...
12
by: Paul Rubin | last post by:
Let's say you have a SocketServer with the threading mix-in and you run serve_forever on it. How can you shut it down, or rather, how can it even shut itself down? Even if you use a...
3
by: Magnus Lycka | last post by:
I have a socket server like below which I want to exit when it's out of data. If I interrupt the client, I'll get a broken pipe on the server side, and after a Ctrl-C, I can restart the server...
4
by: google | last post by:
Dear newsgroup, I give up, I must be overseeing something terribly trivial, but I can't get a simple (Java) applet to react to incoming (python) SocketServer messages. Without boring you with...
12
by: rbt | last post by:
I have written a python socketServer program and I have a few questions that I hope the group can answer... here is a simple version of the server: class...
0
by: Tomi Hautakoski | last post by:
Hello, I'm a Python newbie trying to figure out how to use SocketServer with IPv6. I would like to set up a TCPServer working like below but how to tell SocketServer I need to use AF_INET6? ...
4
by: id.engg | last post by:
logFileName = 'log.txt' logfile = open(logFileName, "a") class MyUDPServer(SocketServer.UDPServer): def server_bind(self): self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 8388608)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.