Search code examples
httpmemcachedtelnet

why can we use telnet to connect http or memcached?


I use to think that telnet, http and memcached use different protocol, but surprisely, we can use telnet to connect http and memcached server.

why?


Solution

  • Many protocols are simply ASCII characters, in a certain sequence/order, back and forth between client and server. And Telnet was one of the first text-based protocols developed (in 1969, per Wikipedia). Protocols that followed later, like FTP, SMTP, HTTP, etc all built on that text-based protocol. And later, things like memcached (and Redis) did as well; it is easier to debug a text-based protocol, since a human can easily "read" the messages going back and forth.

    And to say that memcached protocol, FTP, SMTP, HTTP, etc are different protocols is true -- but this does not mean that they have things in common, such as being text-based.

    There are many non-text-based protocols as well (e.g. SSH, TLS, others); for these, using Telnet will not work. Telnet, then, is such a simple network client that transmits text messages that it can be used to perform almost any other text-based protocol "manually".

    Hopefully this helps!