标签:recv 客户 client 网络 lis close bind port int
基于tcp的socket
服务端
import socket
server = socket.socket()
server.bind((‘127.0.0.1‘,8080))
server.listen()
coon,addr = server.accept()
ret = coon.recv(1024)
print(ret)
coon.send(b‘hi‘)
coon.close()
server.close()
客户端
import socket
client = socket.socket()
client.connect((‘127.0.0.1‘,8080))
client.send(b‘hello‘)
res = client.recv(1024)
print(res)
client.close()
标签:recv 客户 client 网络 lis close bind port int
原文地址:https://www.cnblogs.com/zhangrenguo/p/9918320.html