SocketServer returns bad file descriptor
phillip
phillip at transwitch.co.za
Wed Jul 11 10:22:04 EDT 2001
I use the following from an example
class TestHandler(SocketServer.StreamRequestHandler):
def handle(self):
import string
self.wfile.write ("hello\r\n")
while 1:
data=self.rfile.readline(512)
data=string.strip(data)
self.wfile.write (data + "\r\n")
server=SocketServer.ThreadingTCPServer( ('',10002), TestHandler)
server.serve_forever()
and for the client :
tcpCliSock = socket(AF_INET, SOCK_STREAM)
tcpCliSock.connect(ADDR)
while 1:
data = raw_input('> ')
if not data: break
tcpCliSock.send(data)
data = tcpCliSock.recv(BUFSIZ)
if not data: break
print data
tcpCliSock.close()
But every time I connect I get the following error :
self.rfile + self.connection.makefile('rb', self.rbufsize) error: (9,
'Bad file descriptor')
Any thoughts?
Phill
More information about the Python-list
mailing list