这种情况客户端关闭;服务端也自动退出了
node1:/root/test#cat t1.py
# Echo server program
import socket
HOST = '192.168.137.2' # Symbolic name meaning all available interfaces
PORT =8080 # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
msg=conn.recv(1024)
print(msg.decode('utf8'),type(msg))
if not msg: break
#conn.sendall(data)
print msg
conn.close()