Beyond IRC
Saturday, 1. September 2007, 17:32:43
So, you have been in IRC for a while, and now perhaps wondering that how is this working, how does the client interact?
Well.
The process of a normal IRC connection has basically 4 steps: connecting, logging in, interacting and quitting.
1.) Connecting
When a client connects, it first lets the server do a few things. Most servers I've been on look for a running identd by connecting to the client on a specific port (113?) and if an identd is found the server does.. something
Another thing the server does is that it looks up the hostname, since the server sees the IP of the client that connects in. If the DNS lookup fails, the server sets the IP as the host of the client.
Yet another thing that a server might do is that it pings the client in case if the connection dies immediatly, but I don't really know about this either.
2.) Logging in
While the server is looking up the host, or checking the ident, the client sends two commands to log in, the USER command and the NICK command.
Syntax:
USER <username> * * :<realname> NICK <nick>
When this is done, the server sends some information and the MOTD.
3.) Interacting
OK, we have logged in and the server has accepted us in. The next thing to do is to join channels, send messages, set modes, etc..
Since you already know what everything is, I'll just give the raw commands
Ping/pong
Incoming:
PING :<server?>
Reply (mandatory):
PONG :<pingcode>
Join/part
JOIN <#channel> PART <#channel>
Send a message/notice
PRIVMSG <nick/#channel> :<message> NOTICE <nick/#channel> :<message>
Set a mode
MODE <nick/#channel> <mode> [args]
User-targeted actions
KICK <#channel> <nick> [reason] INVITE <nick> <#channel>
IRC-Operator actions
OPER <username> <password> KILL <nick> <reason> GLINE <nick/uhost> [duration] :<reason> KLINE <nick/uhost> [duration] :<reason> ZLINE <nick/uhost> [duration] :<reason> SHUN <nick/uhost> [duration] :<reason> SPAMFILTER <add/del> <target> <action> <duration> <regexp>
NOTE: The Spamfilter is a bit tricky. More information in the UnrealIRCd Documentation.
NOTE: These commands are based on UnrealIRCd. I do not know do these work exactly alike in other ircds. To get the ircd name and version, use
VERSION
4.) Quitting
OK, we've chatted enough, kicked a few users out and glined one. Now let's get out of here.
Quit
QUIT [:<reason>]
The server will now show a quit message to the other clients and terminate your connection.









zomg # 3. September 2007, 05:12
When connecting, the server doesn't ping the client. It doesn't have to. If the TCP packets are reaching the client, it is still there. Some servers do actually send an actual PING and expect a PONG to that, but other than that they don't ping when connecting.
You actually forgot to mention that if you receive a PING from the server, you need to reply with a PONG that has the same number sequence, or otherwise the server will drop you.