如何选择协议?
因此,我制作了将图片发送给客户端的服务器。但是,当扣除数据包时,我看到数据包的协议是http。为什么是HTTP,但没有其他?
import socket
file_to_return = open(r"C:\Users\hadad\Desktop\webroot\imgs\abstract.jpg", 'rb')
file_content = file_to_return.read()
server_socket = socket.socket()
server_socket.bind(("0.0.0.0", 80))
server_socket.listen()
client_socket, client_address = server_socket.accept()
client_socket.send(file_content)
so I have made server which sends a picture to client. but when snaffing the packets I see that the protocol of the packet is HTTP. why would it be HTTP but no other?
import socket
file_to_return = open(r"C:\Users\hadad\Desktop\webroot\imgs\abstract.jpg", 'rb')
file_content = file_to_return.read()
server_socket = socket.socket()
server_socket.bind(("0.0.0.0", 80))
server_socket.listen()
client_socket, client_address = server_socket.accept()
client_socket.send(file_content)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
端口80通常是HTTP服务的端口。但是,没有什么可以阻止某人在80港口上忽略惯例并运行完全不同的服务 /协议。
当然,这样做这种事情的人有可能为自己造成麻烦和对他人烦恼。
协议映射的标准端口#由IANA定义:
在典型的linux/unix系统上,标准端口分配也列在
/etc/code>文件中。
因为明智人们遵循惯例。
Port 80 is conventionally the port for an HTTP service. But nothing stops someone from ignoring the conventions and running a completely different service / protocol on port 80.
Of course, people who do that kind of thing are liable to cause trouble for themselves and annoyance for other people.
The standard port # to protocol mappings are defined by IANA:
On a typical Linux / UNIX system, the standard port assignments are also listed in the
/etc/services
file.Because sensible people follow the conventions.