Index: trunk/BNC/bncconst.h
===================================================================
--- trunk/BNC/bncconst.h	(revision 137)
+++ trunk/BNC/bncconst.h	(revision 138)
@@ -1,4 +1,6 @@
 #ifndef BNCCONST_H
 #define BNCCONST_H
+
+enum t_irc {failure = -1, success}; // return code
 
 class t_CST {
Index: trunk/BNC/bncgetthread.cpp
===================================================================
--- trunk/BNC/bncgetthread.cpp	(revision 137)
+++ trunk/BNC/bncgetthread.cpp	(revision 138)
@@ -37,4 +37,5 @@
   _socket     = 0;
   _timeOut    = 10*1000;  // 10 seconds
+  _nextSleep  =  1;       //  1 second
 }
 
@@ -102,5 +103,5 @@
 // Init Run
 ////////////////////////////////////////////////////////////////////////////
-void bncGetThread::initRun() {
+t_irc bncGetThread::initRun() {
 
   // Send the Request
@@ -113,5 +114,5 @@
 
   if (!_socket) {
-    return exit(1);
+    return failure;
   }
 
@@ -123,10 +124,10 @@
     if (line.indexOf("ICY 200 OK") != 0) {
       emit(newMessage(("Wrong Caster Response:\n" + line).toAscii()));
-      return exit(1);
+      exit(1);
     }
   }
   else {
     emit(newMessage("Response Timeout"));
-    return exit(1);
+    return failure;
   }
 
@@ -148,7 +149,8 @@
     else {
       emit(newMessage(_staID + " Unknown data format " + _format));
-      return exit(1);
-    }
-  }
+      exit(1);
+    }
+  }
+  return success;
 }
 
@@ -157,5 +159,8 @@
 void bncGetThread::run() {
 
-  initRun();
+  if ( initRun() != success ) {
+    emit(newMessage("initRun failed, reconnecting"));
+    tryReconnect();
+  }
 
   // Read Incoming Data
@@ -194,4 +199,14 @@
 ////////////////////////////////////////////////////////////////////////////
 void bncGetThread::tryReconnect() {
-
-}
+  while (1) {
+    delete _socket; _socket = 0;
+    sleep(_nextSleep);
+    if ( initRun() == success ) {
+      break;
+    }
+    else {
+      _nextSleep *= 2;
+    }
+  }
+  _nextSleep = 1;
+}
Index: trunk/BNC/bncgetthread.h
===================================================================
--- trunk/BNC/bncgetthread.h	(revision 137)
+++ trunk/BNC/bncgetthread.h	(revision 138)
@@ -7,4 +7,5 @@
 
 #include "RTCM/GPSDecoder.h"
+#include "bncconst.h"
 
 class bncGetThread : public QThread {
@@ -27,9 +28,10 @@
  protected:
    virtual void run();
+
  private:
-   void initRun();
-   void tryReconnect();
-   void message(const QString&);
-   void exit(int exitCode = 0);
+   t_irc initRun();
+   void  message(const QString&);
+   void  exit(int exitCode = 0);
+   void  tryReconnect();
    GPSDecoder* _decoder;
    QTcpSocket* _socket;
@@ -38,4 +40,5 @@
    QByteArray  _format;
    int         _timeOut;
+   int         _nextSleep;
 };
 
