Separate the wifi connection code and use it to ensure we have a connection before attempting a TCP connection. Hopefully this will fix the issue that we stop receiving data after awhile.