标签:color 客户 lis server code pytho class accept port
服务端代码:
import socket server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.bind((‘127.0.0.1‘, 8080)) server.listen(1) while True: conn, addr = server.accept() print(addr) data = conn.recv(1024) print(data) conn.send(b‘This is server.‘) conn.close()
客户端代码:
import socket client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect((‘127.0.0.1‘, 8080)) client.send(b‘Who are you?‘) data = client.recv(1024) print(data) client.close()
标签:color 客户 lis server code pytho class accept port
原文地址:https://www.cnblogs.com/yutb/p/12100256.html