Yes you should be checking the return of *every* socket call. I usually use wrapper function which do it for me.
I found the
IRC spec and I am not sure you are following it correctly. I think you need both "CR" and "LF" which would mean messages end in "\r\n". See more
here.
You should also be able to telnet into the server and test out the commands manually if you wish.