Hmm... even if I am not skilled perhaps I found an error... I mean... It seems to me that your connection routine doesn't actually use "server" and "port" to connect to IRC (I thought "port" was a number not char*...).
I am not sure of this, becouse it is a lot advanced for me (and too windows-specific... I am used to search and use a multi-platform library when I try to develop a thing in order to make source more portable and easier to develop/mantain). I cannot go deeper due to my limits