What is the difference between a port number and a protocol number? [closed]

大憨熊 提交于 2019-11-30 08:03:57

You can think of a port as a phone extension, with the computer's IP address being like its phone number. You can call the number (IP address) to talk to the computer, then dial the extension (port) to talk to a specific application. An application needs to be listening on a port in order to communicate.

A protocol is just the language that the two applications on either end of a conversation agree to speak in. If your application is sending streams of bytes to my application, my application needs to know how to interpret those bytes.

Kent Boogaart

Protocol = how to communicate, Port = where to communicate

A protocol is an agreement on how to interpret data and how to respond to messages. They generally specify message formats and legal messages. Examples of protocols include:

A port is part of socket end point in TCP and UDP. They allow the operating system to distinguish which TCP or UDP service on the host should receive incoming messages.

The confusion generally arises because, a number of ports are reserved (eg. port 80) and are generally listened to by severs expecting a particular protocol (HTTP in the case of port 80). While messages send to port 80 are generally expected to be HTTP messages, there is nothing stopping an non-HTTP server from listening on port 80 or an HTTP server from listening on an alternative port (for example 8080 or 8088).

Port = Place where ships come in
Protocol = How the cargo is loaded on the ship

A protocol is a specification for how two devices should exchange data in a way that they can both understand. A port is kind of a numbered 'tag' that helps a computer decide who should receive an incoming piece of data.

Many protocols have a port that they run on by default; this makes it easier to discover them or configure applications that use them. But that's not a hard rule; they could always listen on a different port, as long as anyone contacting them knew about the change.

Everyone is right: my favorite analogy is the one of the ships. Port: where cargo is loaded, Protocol: how the cargo is loaded/unloaded.

This wikipedia article might help you a little.

http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

ports = ears, mouth, eyeball, touch
protocols = English, Spanish, Sign Language, Braille

in Simple port means to whom you communicate. & Protocol means how to communicate or way of communication.

Alnitak

In IP terms, a protocol number is the value assigned to the Layer 4 protocol carried within IP, e.g. 6 for TCP, 17 for UDP, as often found in the /etc/protocols file on most UNIX systems.

A port number is used within the UDP and TCP headers to represent different higher level protocols carried within those protocols, e.g. 25 for SMTP, 80 for HTTP, etc, per /etc/services.

A port is just a channel that you select for the communication, and the protocol determines how the communication is done. A certain protocol usually uses a specific port, like port 80 for HTTP, port 21 for FTP.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!