问题
I know there are a lot of different comminucation protocals
like: http, tcp, ssh, socks5, SMTP, POP,
etc.
I also know that to achieve a comminication, we need to connect localhost:localport
to remotehost:remoteport
. For example, if we google something, we would connect a random local port
to www.google.com: 80
. If we ssh
a remote host, we would connect a random local port
to remotehost: 22
.
My question is: Are communication protocol Half-duplex or Full-duplex?
I guess the answer is Half-duplex
. Because I think in http
connection, at first we send the request from localhost:localport
to remotehost:80
, and then the remote server send its response from remotehost:80
to localhost:localport
. Similarly, in ssh
connection, at first we sent the ssh
commands to remote host, after receiving the commands, the remote host do something and send the results back to the local host.
So I think in one connection between localhost:localport
and remotehost:remoteport
, the message is sent either from localhost:localport
to remotehost:remoteport
, or from remotehost:remoteport
to localhost:localport
.
Am I right?
回答1:
As explained in this article:
SSH is a bidirectional full duplex protocol, which means that it’s not synchronous like HTTP where you need to send a message for a response to happen.
With SSH the remote host might want to tell you something even if you have remained silent. This connector uses a callback flow approach to decouple the “sending” operation from the “receiving” operation.
As documented in this IETF draft, most implementations do allow full-duplex HTTP (for 2xx responses).
Full-duplex HTTP follows the basic HTTP request-response semantics but also allows the server to send response body to the client at the same time when the client is transmitting request body to the server.
Requirements for full-duplex HTTP are under-specified in the existing HTTP (Hypertext Transfer Protocol -- HTTP/1.1) specification, and this memo intends to clarify the requirements of full-duplex HTTP on top of the basic HTTP protocol semantics.
来源:https://stackoverflow.com/questions/65545577/are-communication-protocol-half-duplex-or-full-duplex