I'm looking to write an IRC client in C, the trouble is I'm a bit of an IRC noob and I don't know exactly how IRC servers accept connections.
My English isn't too good, would someone be able to show me some pseudocode for an IRC connection?
It's a TCP, line-based protocol. Just send something like this:
NICK MyNickname
USER MyUser 1 1 1 :I am awesome
Other than that, just respond to a PING
with a corresponding PONG
. Example:
$ telnet irc.freenode.net 6667
:morgan.freenode.net NOTICE * : Looking up your hostname...
:morgan.freenode.net NOTICE * : Checking Ident
:morgan.freenode.net NOTICE * : No Ident response
:morgan.freenode.net NOTICE * : Found your hostname
I sent:
NICK MyNickname
USER MyUser 1 1 1 :I am awesome
I got:
:morgan.freenode.net 001 MyNickname :Welcome to the freenode Internet Relay Chat Network MyNickname
The protocol is documented in RFC1459. The biggest change since the RFC was released is that nicknames can now be longer, typically up to 30 characters.