I'm writing python code for IRC client.
I want to understand how IRC client and server communicating each other.
Can anyone give me good tutorial or IRC communication architecture to understand it in depth?
Thanks
The IRC RFC documentation is an important reference, but the most helpful first introduction I've found on communication between IRC client and server was really simple.
First, you need access to a *nix shell (e.g. ssh into your web host running Linux).
In the command line, open up a direct connection to an IRC server using the program 'nc'. Then you can type RFC commands directly, and see the response. Try typing
$ nc wright.freenode.net 6667
PASS whateveryoulike
NICK yournick
USER username 0 * :Real Name
There is output from the server amidst this, but now you've logged into and "registered" your user. Note: your nick isn't registered (ala NickServ), I'm referring to registering a user as outlined in section 3.1 of the RFC 2812 IRC Client Protocol.
You can now join a channel:
JOIN #yourtestchannel
See who's in the channel:
WHO #yourtestchannel
Send yourself a msg:
PRIVMSG yournick Message Text Here
Chat into the channel (send the channel a msg):
PRIVMSG #yourtestchannel Message Text Here
This is especially helpful if you're connected to the same server and channel with a different nick in a real IRC client. You can chat with yourself and msg one nick to the other, and see the "raw" IRC output that you'll have to parse to write your own client or bot.
For example, someone chatting in a channel looks something like this:
:SomeDude28!SomeDude28@hoststring-with_various_parts PRIVMSG #channel :Hey guys, what's up?
Using the RFC, you can play around with whatever functionality you want, and, more importantly, figure out how you'll need to parse things.
Oh, and don't forget to PONG occasionally, or when prompted with a PING, to avoid ping timeout.