Simple main loop to exchange data with a remote device