如何选择协议?

发布于 2025-02-02 13:38:49 字数 407 浏览 1 评论 0原文

因此,我制作了将图片发送给客户端的服务器。但是,当扣除数据包时,我看到数据包的协议是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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一花一树开 2025-02-09 13:38:49

端口80通常是HTTP服务的端口。但是,没有什么可以阻止某人在80港口上忽略惯例并运行完全不同的服务 /协议。

当然,这样做这种事情的人有可能为自己造成麻烦和对他人烦恼。

协议映射的标准端口#由IANA定义:

在典型的linux/unix系统上,标准端口分配也列在/etc/code>文件中。


为什么它是http,但没有其他?

因为明智人们遵循惯例。

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.


Why would it be HTTP but no other?

Because sensible people follow the conventions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文