When debugging mode is enabled, and the socket variable is NULL, we will try to dereference it to print the debug message. Split the checks to avoid that. Change-Id: I0e0643900d3d8463937b7fd47b21cd91cf49b73c