\n
others require \r\n
\r
using
$ stty -a
and looking for lnext
. It is ^V
for me.
\r\n
line endings$ telnet localhost 6379
-c
or -C
to send \r\n
$ echo "get foo" | nc -C localhost 11211 > output.txt
$ socat - OPENSSL:duckduckgo.com:443
My wife wants you to know that it is "tacos" backwards
$ openssl s_client -connect www.google.com:443
Example: Graphite
\n
line endingsmetric.path.name value timestamp\n
Example:
wx.temp.chicago 78.2 1621913119\n
$ echo "wx.temp.chicago 78.2 `date +%s`" | nc localhost 2003
Example: IRC
\r\n
, most servers accept \n
:prefix command arg1 arg2 ... argN\r\n
:
IRC is noisy, separate input from output
In one terminal do
touch irc-out; tail -f irc-out
In another terminal do
You'll see welcome messages in the other terminal
If the server sends you
PING :something
You need to (rather promptly) reply
PONG :something
... or it will drop your connection
Send
JOIN #test
Server Sends ("Replies")
:mynickname!myusername@$HOST JOIN #test
... to you and everyone in the channel
Send a message
PRIVMSG #test :Hello World!
Server Sends
:mynickname!myusername@$HOST PRIVMSG #test :Hello World!
... to everyone else in the channel
Example: Memcached
\r\n
set key flags expiration length\r\n
set key flags expiration length\r\n
set greeting 0 0 12\r\n
payload bytes, correct length\r\n
Hello World!\r\n
STORED\r\n
ERROR\r\n
CLIENT_ERROR\r\n
SERVER_ERROR\r\n
One key
get key1\r\n
Multiple keys
get key1 key2 key3\r\n
For each key requested
VALUE key flags length\r\n
payload bytes, correct length\r\n
Then finally
END\r\n
Example: HTTP
\r\n
, most servers accept \n
METHOD PATH HTTP/VERSION\r\n
Example:
GET / HTTP/1.1\r\n
HTTP/VERSION STATUS MESSAGE\r\n
Example:
HTTP/1.1 200 OK\r\n
\r\n
\r\n
Connection: close
Content-Length
bytes and \r\n
Transfer-Encoding: chunked
Go play with text-based protocols!