server端和client端
1、server端:
import socket
server=socket.socket()
server.bind(('localhost',8080))
server.listen()
conn,attr=server.connect()
data=conn.recv(10240)
re=b'.....'
conn.send(re)
server.close
2、client端
import socket
client=socket.socket()
client.connect(('localhost',8080))
client.send(poat_data.encode('utf-8'))
data=client.recv(10240)
print('recv_data:',data)
client.close()
注:accept返回套接字对象和客户端地址。