C# isn’t my native language, but some general notes:
I do not know what g_IRC.readMessage() looks like, but it is returning a null value. But, your object is being assigned null rather than a String (I assume String). Check to see what g_IRC.readMessage() is providing, put a null check where you use that g_readData later. Your assumption is possibly incorrect, if g_IRC was null, then it would throw an error trying to access a member of a null object. I would look into how readMessage() works - it might even valid that it returns null and you should account for that.
System.IndexOutOfRangeException: you are walking objects in a foreach, which basically makes them arrays.
I am not familiar with the C# implementation of sockets, but I would put a try { } catch { } style block around that and make sure that an error isn’t occurring.
Sorry these are vague answers, like I said, C# is not my first language.
Cheers