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 8000
Connected to
Escape character is ‘^]’. NOTICE Auth :*** Looking up your hostname…
nick stratosg NOTICE Auth :*** Found your hostname (localhost) — cached
user stratosg 8 * name surname NOTICE Auth :Welcome to! 001 stratosg :Welcome to the IRC Network stratosg!stratosg@localhost 002 stratosg :Your host is, running version InspIRCd-1.1.8+VenezuelanBeaver 003 stratosg :This server was created 18:08:28 Jun 1 2007 004 stratosg InspIRCd-1.1.8+VenezuelanBeaver Rinorsw MRbhiklmnoprstv bhklov 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 005 stratosg TOPICLEN=307 KICKLEN=255 MAXTARGETS=20 AWAYLEN=200 CHANMODES=b,k,l,MRimnprst FNC MAXPARA=32 ELIST=MU :are supported by this server 375 stratosg message of the day
—–message of the day here —— 376 stratosg :End of message of the day. 251 stratosg :There are 1 users and 1 invisible on 1 servers 254 stratosg 1 :channels formed 255 stratosg :I have 2 clients and 0 servers 265 stratosg :Current Local Users: 2 Max: 3 266 stratosg :Current Global Users: 2 Max: 3
join #main
:stratosg!stratosg@localhost JOIN :#main 353 stratosg = #main :@leeBot stratosg 366 stratosg #main :End of /NAMES list.
privmsg #main hello there
part #main
:stratosg!stratosg@localhost PART #main

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!