Add a retrywait to prevent quitting when connection is lost

Before, a lost connection would cause resnet.py to quit, and not
restart when the connection returns. This modification retries until
the connection is successful, preventing program restarts.