A quick example for you:
###
import SocketServer
class EchoRequestHandler(SocketServer.BaseRequestHandler ):
def setup(self):
print self.client_address, 'connected!'
self.request.send('hi ' + str(self.client_address) + '\n')
def handle(self):
while 1:
data = self.request.recv(1024)
self.request.send(data)
if data.strip() == 'bye':
return
def finish(self):
print self.client_address, 'disconnected!'
self.request.send('bye ' + str(self.client_address) + '\n')
#server host is a tuple ('host', port)
server = SocketServer.ThreadingTCPServer(('', 5000), EchoRequestHandler)
server.serve_forever()
###
Telnet to localhost 5000 and any data you sent will be echoed back to you... send 'bye' and the connection is closed
On 24 Jan 2005 06:25:18 -0800
"assaf" <as****@ixi.com> wrote:
i am try to create a server
what am i suppose to send to SocketServer.TCPServer
what is the client_address ("127.0.0.1:80" ?)
and BaseRequestHandler = ?
thanks
--
http://mail.python.org/mailman/listinfo/python-list