handling read errors at all and error handling for writes was never being used. Now the socket disconnects if a read or write fails on the socket for any reason except EINTR. Also added <netinet/in.h> to includes in CNetwork.h because it's needed on some platforms.