Created a thread to control the client connection when connect is called so it doesn't have to be done every time