Internet Relay Chat, an internet protocol/system for real-time chat. The current version of the protocol is defined in RFC 1459. However, many changes in how things actually work have occured since then, and RFCs 2810, 2811, 2812 and 2813 have replaced it in some aspects, although the original RFC is really the authorative document.
IRC networks are typically made up of multiple servers, to which individual clients (ie, people) connect. The protocol defines both client<->server and server<->server communications, which are in fact very similar. There is nothing to stop an IRC server using a different protocol for server<->server communications anyway, since it's not really viable to connect two different ircd versions (IRC daemons, ie two different versions of the server software) together, as they have extended and changed the protocol significantly.
People can talk both in public (or private) channels and in private messages (queries). Networks often provide irc services, and people often run client-side scripts and bots to control/manage channels and the such.
A typical few minutes of a chat as seen from a client (it's usual to connect to IRC using a specialized program, such as mIRC, irssi, BitchX or X-Chat) might consist of the following, for instance (this is a sample from #everything):
! TallRoo (~firstname.lastname@example.org) has left #everything
* getzburg hides from the ninja
<jethro_bodine> snowy's hair is a bit less wonky
<dmd> Well she had just gotten out of the shower.
* Snowbelle laughs
<mkb> my girlfriend doesn't look anything like either of those
<mkb> except for the glasses really
<dmd> Which is why she's got that "get that damn camera out of my face" look.
! fuzzie|dinner has changed her nick to fuzzie
Here, you can see someone leaving the channel (a "part" - people can attach an optional message to their parts/quits if they wish), people talking
(including special messages called actions, which you've probably seen in the chatterbox (/me), and me, changing my nickname.
Operators/Voiced Users and Modes
Channel operators, set by mode +o within a channel, are able to modify the ban list of that channel, kick (forcefully remove) people from that channel, change that channels modes, change the topic if +t is set on that channel, and many other things. Only opped and voiced users (mode +v) are able to speak if the channel is set mode +m ('moderated'). Other users in the channel can only listen. It is also important to mention +n, which means 'no outside messages': this specifies that users must actually be in the channel in order to be allowed to send messages to it. This is set for almost all channels.
Note that IRC operators (referred to in the literals when you initially connect tothe server) are something completely different; they are people with power over the IRC servers themselves, who usually have full control to ban you from the server you are on or the whole network, to forcefully kick you off the network, and other such things.
"But what are modes?", I hear you ask. They're single letters, sometimes (in the case of channels, with +b for bans, +o for operators, +v for voices) associated with an IRC username, which specify special options associated with a user or channel. When an option is set, the letter is prefixed with a +. To set the option, the command is 'MODE +x' where 'x' is the option letter, and to unset this, just replace the + (plus) with a - (minus). Many users set themselves 'invisible', meaning they don't show up in various list commands as being online, by setting their mode +i. Many modes cannot be set by normal users, such as the user +o (IRC operator) mode, for obvious security reasons, and of course, as I said above, only channel operators can modify channel modes.
You'll probably be happy to know that most IRC clients wrap this all up in a bunch of checkboxes to set/unset modes.
A basic walkthrough of the client protocol
This is a bit complicated, but worth knowing, in my opinion.
It's sometimes useful to be able to connect to IRC via telnet. I'm going to step through a simple session of this, which will also serve to help me illustrate the basics of how the protocol works. I'm not going to cover the server protocol here; basically it works by simply relaying messages through the network to all other servers. Take a look at the netsplit node for an explanation of the 'tree' layout of IRC networks. Note that, in the ouput below, I manually wrapped one of the notice lines, to try and stop this writeup from being wider than it already is.
fuzzie@junglejazz:/home/e2stuff$ telnet moo.slashnet.org 6667
Connected to leaf.lumiere.net.
Escape character is '^]'.
:moo.slashnet.org NOTICE * :*** Looking up your hostname...
:moo.slashnet.org NOTICE * :*** Found your hostname in cache
:moo.slashnet.org NOTICE * :*** Checking ident...
:moo.slashnet.org NOTICE * :*** Checking for open SOCKS server...
:moo.slashnet.org NOTICE * :*** No ident response; username prefixed with ~
:moo.slashnet.org NOTICE * :*** No SOCKS server found
USER moose fuzzie.warpedgames.com moo.slashnet.org :Alyssa Milburn
:moo.slashnet.org NOTICE moose :*** If you need assistance with connecting to this server, moo.slashnet.org,
please refer to: http://www.slashnet.org/
:moo.slashnet.org 001 moose :Welcome to Internet Relay Chat email@example.com
:moo.slashnet.org 002 moose :Your host is moo.slashnet.org, running version cyclone0.3.1.1
:moo.slashnet.org 003 moose :This server was created Thu Apr 11 2002 at 01:32:22 PDT
:moo.slashnet.org 004 moose moo.slashnet.org cyclone0.3.1.1 acdfgikloszCOZ abiklmnopstvR
:moo.slashnet.org 008 moose NOQUIT TOKEN WATCH=128 SAFELIST :are available on this server
:moo.slashnet.org 251 moose :There are 306 users and 328 invisible on 8 servers
:moo.slashnet.org 252 moose 16 :operator(s) online
:moo.slashnet.org 253 moose 1 :unknown connection(s)
:moo.slashnet.org 254 moose 184 :channels formed
:moo.slashnet.org 255 moose :I have 131 clients and 2 servers
:moo.slashnet.org 265 moose :Current local users: 131 Max: 154
:moo.slashnet.org 266 moose :Current global users: 634 Max: 851
:moo.slashnet.org 375 moose :- moo.slashnet.org Message of the Day -
:moo.slashnet.org 372 moose :- 27/7/2002 16:49 +00:00
:moo.slashnet.org 372 moose :- ___ _ _ _ _ ___ _____
:moo.slashnet.org 372 moose :- / __|| | __ _ ___| |_ | \| || __||_ _|
:moo.slashnet.org 372 moose :- \__ \| |/ _ |(_-<| ' \ | . || _| | |
(insert the rest of the MOTD here, omitted for brevity)
:moo.slashnet.org 376 moose :End of /MOTD command.
:firstname.lastname@example.org JOIN :#monkeysoypants
:moo.slashnet.org 332 moose #monkeysoypants :http://www.rathergood.com/jamie/ | edev: user data - Go read.
:moo.slashnet.org 333 moose #monkeysoypants fuzzie 1027734235
:moo.slashnet.org 353 moose = #monkeysoypants :moose @Xen @bz2 wamckee|coding fuzzie Helios +Stat-bot
:moo.slashnet.org 366 moose #monkeysoypants :End of /NAMES list.
:ChanServemail@example.com NOTICE moose :hola!
PRIVMSG #monkeysoypants :hi
:firstname.lastname@example.org PRIVMSG #monkeysoypants :hi, moose.
:email@example.com PRIVMSG #monkeysoypants :ACTION waves at moose.
PRIVMSG #monkeysoypants :bye.
ERROR :Closing Link: moose[m225-mp1.cvx2-a.bri.dial.ntli.net] (Quit: whee.)
Connection closed by foreign host.
Okay, now let's run through this bit-by-bit. First, I telnet to port 6667 on the server, which is the usual IRC port. Then, the server sends several NOTICE commands. Note that they're prefixed with the server name, with a colon in front - this is the way all IRC messages are structured, they're in plain-text, on a single line, with a colon (usually) followed by the source of the message (a server or another user on the network, typically).
It then waits for me to send a USER command - the portions in italics are those portions I typed - which has four parameters:
- My requested username (full IRC usernames are made up of three parts, a nickname, a username and a hostname. The username is typically confirmed by attempting to contact identd on the connecting host (computer); most IRC clients fake this if they're running on a host without identd running (usually only *nix hosts). As you can see from the initial NOTICEs, my username will be prefixed with a tilde character as I the server could not connect to identd. This basically dates back to the time when most people connected to IRC networks from multi-user hosts; it was a reliable way to identify individual people on a computer, mainly for banning purposes. Nowadays bans are usually based on just hostnames, instead.
- My hostname. This is usually ignored, the server works it out itself, as you can again see from the notices; however, when the server passes my USER command onto other servers on the network, it will replace this hostname with my real hostname, so the other servers don't have to work it out.
- The servername. Almost always ignored for the same reason as the hostname, and again replaced so the other servers know whch server the user is connected to.
- My realname. This can be whatever I want, and is made available to other users when they use the /whois command. Note that I have prefixed it with a colon, which means "Use characters until the end of the line to make up this parameter"; without it, only the letters up to the first space would be used (so my realname would be 'Michael', in this example). It's obviously vital to use it when sending messages.
My next command is a NICK command, which has one parameter: the nickname I want. I can change this later by simply sending another NICK command. After I've sent both USER and NICK, some servers may request a password, which is supplied via the PASS command, but in this case the server only requires those two.
The server then sends a bunch of notices and literals. Literals are essentially specialised notices of a certain type which are defined in the RFC - you can guess at them, as plain-text versions are also included. Note that IRC clients can easily parse the necessary data out and use it in, for instance, GUI elements, or convert it to different languages.
I then send a 'JOIN #monkeysoypants' command, which, as you can guess, is a command which tells the server to place me inside the channel called '#monkeysoypants'. Channels are usually prefixed with '#', although there are different prefixes which do different things (such as channels which are only present on one server of the network, or channels in which there are no operators).
I am now part of the channel, and recieve a message telling me that I have joined (other users inside the channel would recieve the same message). If I wasn't inserted into the channel, an error message would be returned, such as the channel needing a key (password) in order to be joined, or me being banned from the channel for some reason. A ban consists of the three portions of an IRC username I described above, and can use the '*' wildcard if necessary. For instance, a typical ban might be 'l33tdude@~bob@*.aol.com', which means anyone with a nickname of 'l33tdude' and an ident (username) of '~bob', with a hostname ending in aol.com, is banned from joining the channel. Note that some networks support ban 'exceptions', allowing specific masks to be allowed to join the channel despite a ban, and also that if a ban is set while people matching the ban mask are still in the channel, they are unable to speak unless voiced or opped (more on that below).
The next line, literal 332, is a 'TOPIC' literal, consisting of two parameters: the channel name, and the topic for that channel. The line after that, literal 333, provides a nickname and a timestamp, telling you who last changed the topic and when. If a channel has mode '+t' (more on modes below), then only channel operators can change the topic; otherwise, anyone is able to.
The next two lines consist of a 'NAMES' literal, containing a list of nicknames, and a literal notifying you that the 'NAMES' list has finished; this is necessary as if a large number of users are in a channel, several 'NAMES' literals may be sent. You may notice that some of these nicknames are prefixed by '@' or '+': '@' means channel operator, and '+' means voiced, again, see the section below foran explanation of what these are.
ChanServ, a part of IRC services on slashnet, then NOTICEs me a welcome message, as it has been configured to do. I then send a message to the channel using the PRIVMSG command (by replacing the channel name with a nick in the PRIVMSG command, I could send a message to an individual user). I then recieve a reply from someone else in the channel, followed by an action (/me) from them, and then I send another message and then a QUIT command, causing the server to drop me.
Did I miss anything obvious? /msg me and tell me.