#!/usr/bin/env python
#-*- coding:utf- -*-
import SocketServer
class MySocker(SocketServer.BaseRequestHandler):
def handle(self):
print self.request,self.client_address,self.server
conn = self.request
conn.send('hello world!')
while True:
data = conn.recv()
if data == 'exit':
break
conn.send('hahah')
ip_addr = ('127.0.0.1',)
server = SocketServer.ThreadingTCPServer(ip_addr,MySocker)
server.serve_forever()
############################################################
client
#!/usr/bin/env python
#-*- coding:utf- -*-
import socket
client = socket.socket()
ip_port = ('127.0.0.1',)
client.connect(ip_port)
while True:
data = client.recv()
print data
name = raw_input('please data: ')
client.send('name')
if name == 'exit':
break