标签:
金角相关博文。银角相关博文。
import socket ip_port = (‘127.0.0.1‘,9999) sk = socket.socket() sk.connect(ip_port) sk.sendall(bytes(‘请求占领地球‘,‘utf8‘)) server_reply = sk.recv(1024) print(str(server_reply,‘utf8‘)) sk.close()
import socket ip_port = (‘127.0.0.1‘,9999) sk = socket.socket() sk.bind(ip_port) sk.listen(5) while True: print(‘server waiting...‘) conn,addr = sk.accept() client_data = conn.recv(1024) print(str(client_data,‘utf8‘)) conn.sendall(bytes(‘不要回答,不要回答,不要回答‘,‘utf8‘)) while True: client_data = conn.recv(1024) if not client_data.decode():break print(str(client_data,‘utf8‘)) conn.send(client_data) conn.close()
标签:
原文地址:http://www.cnblogs.com/bettybear/p/5537290.html