SocketServer model_use

#!/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
上一篇:集成 AliPay - 支付宝


下一篇:HIVE安装配置