     if (strport.length() > 0)
     {
         localport = strport.toInt();
-        wifly.setPort(localport);
-        wifly.save();
-        wifly.reboot();
+        if(wifly.getPort() != localport) {
+            C64Println("Rebooting WiFly...");
+            wifly.setPort(localport);
+            wifly.save();
+            wifly.reboot();
+            delay(3000);
+        }
     }
 
     localport = wifly.getPort();

{
    int inpint, verbint, optint;        //    telnet parameters as integers

    // Wait for first character for 5 seconds
    inpint = PeekByte(wifly, 5000);

    if (inpint != IAC)
    {

#define ADDR_BAUD_HI       3
#define ADDR_MODEM_ECHO         10
#define ADDR_MODEM_FLOW         11
#define ADDR_MODEM_VERBOSE      12
#define ADDR_MODEM_QUIET        13
#define ADDR_MODEM_S0_AUTOANS   14
#define ADDR_MODEM_S2_ESCAPE    15
#define ADDR_MODEM_DCD_INVERTED 16

#define ADDR_HOST_AUTO    99     // Autostart host number
#define ADDR_HOSTS         100    // to 299 with ADDR_HOST_SIZE = 40 and ADDR_HOST_ENTRIES = 5
