I think your best option might be to use an IRC library. The IRC protocol is fairly simple but large at the same time, to write a complete library would actually be a fair bit of work. On the other hand it's easy to write it yourself since IRC is a text based protocol.
Why don't you take a look at one of these:
- JerkLib - Uses NIO and is event driven
- Sorcix' sIRC - Very compact library, uses listeners
- PircBot - Rather for writing irc bots
- IRClib - Neatly organised compact irc library that has support for SSL
If you're certain you want to write the implementation yourself you can have a look at this.