Index: /applications/editors/josm/plugins/livegps/src/livegps/LiveGpsAcquirer.java
===================================================================
--- /applications/editors/josm/plugins/livegps/src/livegps/LiveGpsAcquirer.java	(revision 25790)
+++ /applications/editors/josm/plugins/livegps/src/livegps/LiveGpsAcquirer.java	(revision 25791)
@@ -121,9 +121,18 @@
         while (!shutdownFlag) {
 
-            try {
-                if (!connected)
+	    while (!connected) {
+		try {
                     connect();
-
-                if (connected) {
+		} catch (IOException iox) {
+		    fireGpsStatusChangeEvent( LiveGpsStatus.GpsStatus.CONNECTION_FAILED, tr("Connection Failed"));
+                    try {
+                        Thread.sleep(1000);
+                    } catch (InterruptedException ignore) {}
+		};
+	    }
+
+	    assert (connected);
+
+	    try {
                     String line;
 
@@ -134,5 +143,5 @@
                     // </FIXXME>
                     if (line == null)
-                        break;
+                        throw new IOException();
 
                     if (JSONProtocol == true)
@@ -146,19 +155,10 @@
                     fireGpsDataChangeEvent(oldGpsData, gpsData);
                     oldGpsData = gpsData;
-                } else {
-                    fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.DISCONNECTED, tr("Not connected"));
-                    try {
-                        Thread.sleep(1000);
-                    } catch (InterruptedException ignore) {}
-                }
             } catch (IOException iox) {
-                connected = false;
-                if (gpsData != null) {
-                    gpsData.setFix(false);
-                    fireGpsDataChangeEvent(oldGpsData, gpsData);
-                }
+                System.out.println("LiveGps: lost connection to gpsd");
                 fireGpsStatusChangeEvent(
                         LiveGpsStatus.GpsStatus.CONNECTION_FAILED,
                         tr("Connection Failed"));
+		disconnect();
                 try {
                     Thread.sleep(1000);
@@ -168,15 +168,8 @@
         }
 
+	System.out.println("LiveGps: Disconnected from gpsd");
         fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.DISCONNECTED,
                 tr("Not connected"));
-        if (gpsdSocket != null) {
-            try {
-                gpsdSocket.close();
-                gpsdSocket = null;
-                System.out.println("LiveGps: Disconnected from gpsd");
-            } catch (Exception e) {
-                System.out.println("LiveGps: Unable to close socket; reconnection may not be possible");
-            }
-        }
+	disconnect();
     }
 
@@ -197,5 +190,5 @@
                 gpsdSocket = new Socket(addrs[i], gpsdPort);
                 break;
-            } catch (Exception e) {
+            } catch (IOException e) {
                 System.out.println("LiveGps: Could not open connection to gpsd: " + e);
                 gpsdSocket = null;
@@ -203,8 +196,6 @@
         }
 
-        if (gpsdSocket == null)
-            return;
-
-        fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.CONNECTING, tr("Connecting"));
+        if (gpsdSocket == null || gpsdSocket.isConnected() == false)
+            throw new IOException();
 
         /*
@@ -248,4 +239,17 @@
             fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.CONNECTED, tr("Connected"));
         }
+    }
+
+    private void disconnect() {
+	assert(gpsdSocket != null);
+
+	connected = false;
+
+        try {
+		gpsdSocket.close();
+		gpsdSocket = null;
+	} catch (Exception e) {
+		System.out.println("LiveGps: Unable to close socket; reconnection may not be possible");
+	}
     }
 
