Fixed the socket issue, cannot check is connected on a socket that has
never been created, thus having null pointer exception.