问题
What is the difference between a port number and a protocol number?
回答1:
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.
回答2:
Protocol = how to communicate, Port = where to communicate
回答3:
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:
- TCP/IP
- HTTP
- SSH
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).
回答4:
Port = Place where ships come in
Protocol = How the cargo is loaded on the ship
回答5:
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.
回答6:
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
回答7:
ports = ears, mouth, eyeball, touch
protocols = English, Spanish, Sign Language, Braille
回答8:
in Simple port means to whom you communicate. & Protocol means how to communicate or way of communication.
回答9:
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
.
回答10:
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.
来源:https://stackoverflow.com/questions/586882/what-is-the-difference-between-a-port-number-and-a-protocol-number