python_day8 socket 网络编程 基本篇
服务端:
server=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
server.bind(('127.0.0.1',80))
server.listen(5)
conn,address=server.accept()
data=conn.recv(1024)
print(data)
conn.send(data.upper())
conn.close()
server.close()
客户端
import socket
client=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
client.connect(('127.0.0.1',80))
client.send('aaa'.encode('utf-8'))
data=client.recv(1024)
print(data)
client.close()