lodef

starting with a little chat: IRC part 1

everybody loves to chat, right? let's take a look at the oldest still-in-use chat protocol out there: the venerable IRC.

transcript
welcome to lodef!

this is a show about simple technologies, right? human-scale
programs and protocols that you can actually fit in your head.
simple technologies can still bring people together, and what better
example than that of IRC.

$ cd ~/src/taverner

over here I've got an IRC server I wrote. I put this codebase
together in a couple weekends. it's under 400 lines of code. but it
works; I've used it to have real conversations with my friends.

$ make count
$ make run

let's start it up. it's listening on port 6667, the standard port
for IRC. now we could connect a real client, or we could use netcat!

$ nc localhost 6667

if you've never used netcat before, it's great. it connects to a
socket and lets you just send data and receive directly and see the
results you get back in the terminal.

IRC wants to know who we are so:

> NICK technomancy
> USER technomancy 0 * technomancy

so the first command sets the nick, which is like ... the actual
name you use on the server. for historical reasons, you also
provide a username and supposed "real name", both of which are more
or less ignored and required for historical reasons.

get used to that, by the way. there's a lot less nonsense here by
volume than a typical modern stack, but there's still plenty of
things we do just because it's always been that way.

anyway now <hacker-voice>I'm in</hacker-voice>

the server is running on the bottom window and it says I've identified
as technomancy; it's accepted my nick and username, and it's introducing
itself in its own weird way. so zero channels exist yet, so let's create
one by JOINing it. back to our netcat session, we're gonna join a
channel called lodef.

> JOIN #lodef

here we go, so no topic set; we're the only inhabitant in the channel.
at this point it doesn't really work to talk with just ourself, so
let's try connecting with a real client. going to use one that's
built in to emacs here, since I'm already in emacs.

$ C-u M-x rcirc localhost RET 6667 RET me2 RET
$ /join #lodef
> say hi

so we're connected using a real client now, and we want to join the
same channel we were in previously, so we can see technomancy is in
here.  if we go back to netcat, we can see that the server has
notified us that me2 has joined and me2 has sent a message to the
server; the PRIVMSG is how every message gets sent. this is the
command, #lodef tells you what was the target of the message, and then
everything after the colon is the content of the message.

so we can send a message back here:

> PRIVMSG #lodef :hello me2

and it just shows up for our other clients!

that's all we got time for now, but this covers the basics of
connecting, sending, and receiving messages. next time we'll write
some code to make an actual bot instead of doing this all by hand.

thanks for watching.