Now here is another post on the “hardcore or masochist” series. It’s been a long time since the last similar post but it’s been a long time since i ever got to explore a protocol. This was a pretty easy one to explore since it is built for chatting. It all started out two decedes ago, back in 1988 by Jarkko Oikarinen. More info on the history and structure of IRC can be found on Wikipedia.

So, i was trying to see how irc can be accessed via telnet. Below is a small dump of an irc connect, join, part and quit.

telnet 127.0.0.1 8000
Trying 127.0.0.1…
Connected to 127.0.0.1.
Escape character is ‘^]’.
:g-lee.no-ip.org NOTICE Auth :*** Looking up your hostname…
nick stratosg
:g-lee.no-ip.org NOTICE Auth :*** Found your hostname (localhost) — cached
user stratosg 8 * name surname
:g-lee.no-ip.org NOTICE Auth :Welcome to stratos.net!
:g-lee.no-ip.org 001 stratosg :Welcome to the stratos.net IRC Network stratosg!stratosg@localhost
:g-lee.no-ip.org 002 stratosg :Your host is g-lee.no-ip.org, running version InspIRCd-1.1.8+VenezuelanBeaver
:g-lee.no-ip.org 003 stratosg :This server was created 18:08:28 Jun 1 2007
:g-lee.no-ip.org 004 stratosg g-lee.no-ip.org InspIRCd-1.1.8+VenezuelanBeaver Rinorsw MRbhiklmnoprstv bhklov
:g-lee.no-ip.org 005 stratosg WALLCHOPS WALLVOICES MODES=19 CHANTYPES=# PREFIX=(ohv)@%+ MAP MAXCHANNELS=20 MAXBANS=60 VBANLIST NICKLEN=31 CASEMAPPING=rfc1459 STATUSMSG=@%+ CHARSET=ascii :are supported by this server
:g-lee.no-ip.org 005 stratosg TOPICLEN=307 KICKLEN=255 MAXTARGETS=20 AWAYLEN=200 CHANMODES=b,k,l,MRimnprst FNC NETWORK=stratos.net MAXPARA=32 ELIST=MU :are supported by this server
:g-lee.no-ip.org 375 stratosg :g-lee.no-ip.org message of the day
—–message of the day here ——
:g-lee.no-ip.org 376 stratosg :End of message of the day.
:g-lee.no-ip.org 251 stratosg :There are 1 users and 1 invisible on 1 servers
:g-lee.no-ip.org 254 stratosg 1 :channels formed
:g-lee.no-ip.org 255 stratosg :I have 2 clients and 0 servers
:g-lee.no-ip.org 265 stratosg :Current Local Users: 2 Max: 3
:g-lee.no-ip.org 266 stratosg :Current Global Users: 2 Max: 3
join #main
:stratosg!stratosg@localhost JOIN :#main
:g-lee.no-ip.org 353 stratosg = #main :@leeBot stratosg
:g-lee.no-ip.org 366 stratosg #main :End of /NAMES list.
privmsg #main hello there
part #main
:stratosg!stratosg@localhost PART #main
quit

In bold there are the commands i issued on the server. Here they are in detail:

  • nick stratosg: I am telling the server what is my nick.
  • user stratosg 8 * name surname: Using this command we give the server a few more details on what is our name, surname conenction mode and server. After this the connection process from our side is complete. The server now sends the message of the day.
  • join #main: After the message of the day we are fully connected to the server. We now can join channels (which is what we do here joining channel main).
  • privmsg #main hello there: We just say a “hello there” to the channel. Every message we send on an irc server is either to the server itself as a command (nick, user etc) or a private message to either a channel (group of users) or a certain user. I need to note here that if we receive a message (let’s say from us) would be something like: “:stratosg!stratosg@host_he_is_in message“.
  • part #main: Finally we part the channel and…
  • quit: close the connection.

As you see for yourself the protocol is pretty easy and straightforward. As always, it is based on an RFC (Request For Comments), the RFC 1459. So, you can check there for further reading.

I would like to make one point before i let you experiment on your own. Do not forget that this is a stream of data meaning that you have to send, receive and then again send and receive. Also, you do not know when the end of the response has come so some kind of expiration on the read should apply in order not to lock read down. Hope it was enlghtining and as always comments are welcome!