单进程串行执行
#!/usr/bin/env python
import socket
HOST='0.0.0.0'
PORT= 9002
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind((HOST,PORT))
s.listen(1)
while True:
conn,addr=s.accept() #accept()函数只接受一个用户连接,另一个用户连接会阻塞
print 'Got a Connection from',addr
while True:
data =conn.recv(1024)
if notdata:break
conn.send(data.upper())
print'Received...:',data
s.close()