This is more like a conceptual question. I need some clarifications.
Today I was learning some socket programming stuff and wrote a simple chat server and chat client based on Beej's Guide to Network Programming. (chat server receives clients message and send messages to all the other clients)
I copied the chat server and I wrote my own chat client.
The chat client is just a program to send stdin
input to server and print socket data from server.
Later I noticed that the guide says I can just use telnet
to connect to the server. I tried and it worked.
I was unfamiliar with telnet and for a long time I don't know what exactly it is.
So now my experience confuses me:
Isn't telnet just a simple TCP send/echo program? What makes it so special to be a protocol thing? My dumb chat client program doesn't create a [application] protocol.
From Wikipedia Communication_protocol :
In telecommunication, a communication protocol is a system of rules
that allow two or more entities of a communications system to transmit
information via any kind of variation of a physical quantity.
What rules does Telnet create? telnet host port
, open a TCP stream socket for raw input/output? That's not a rule.
Best Answer
Telnet is defined in RFC 854. What makes it (and anything else) a protocol is a set of rules/constraints. One such rule is that Telnet is done over TCP, and assigned port 23 - this stuff might seem trivial, but it needs to be specified somewhere.
You can't just send whatever you want, there are limitations and special meaning to some things. For example, it defines a "Network Virtual Terminal" - this is because when telnet was established, there could be many different terminals: A printer, a black/white monitor, a color monitor that supported ANSI codes, etc.
Also, there's stuff like this:
In modern times, most of the stuff isn't really that important anymore (then again, telnet as a protocol isn't being used much anymore, not just because it lacks security) so in practice it boils down to send/echo unless you have to actually interface with terminals.