--- gpilotd/gpilotd.c~	2005-06-25 02:13:44.000000000 -0400
+++ gpilotd/gpilotd.c	2005-06-25 03:17:02.000000000 -0400
@@ -122,7 +122,7 @@
 static int 
 pilot_connect (GPilotDevice *device,int *error) 
 {
-	int sd, listen_sd, pf;
+	int sd, pf;
 	int ret;
     
 	if (device->type != PILOT_DEVICE_NETWORK) {
@@ -147,7 +147,7 @@
 		break;
 	}
 	
-	if ((listen_sd = pi_socket (PI_AF_PILOT, PI_SOCK_STREAM, pf)) < 0) {
+	if ((sd = pi_socket (PI_AF_PILOT, PI_SOCK_STREAM, pf)) < 0) {
 		g_warning ("pi_socket: %s",strerror (errno));
 		if (error) *error = 1;
 		return -1;
@@ -163,37 +163,36 @@
 		device->port = "net:any";
 	}
 
-	ret = pi_bind (listen_sd, device->port);
+	ret = pi_bind (sd, device->port);
 	if (ret < 0) {
 		g_warning (_("Unable to bind to pilot"));
 		if (error)
 			*error = 1;
-		pi_close(listen_sd);
+		pi_close(sd);
 		return 0;
 	}
 
-	ret = pi_listen (listen_sd, 1);
+	ret = pi_listen (sd, 1);
 	if (ret < 0) {
 		g_warning ("pi_listen: %s", strerror (errno));
 		if (error)
 			*error = 2;
-		pi_close(listen_sd);
+		pi_close(sd);
 		return 0;
 	}
 
-	sd = pi_accept_to (listen_sd, NULL,0, device->timeout); 
+	sd = pi_accept_to (sd, NULL,0, device->timeout); 
 	if (sd < 0) {
 		g_warning ("pi_accept_to: %s", strerror (errno));
 		g_warning ("pi_accept_to: timeout was %d secs", device->timeout);
 		if (error)
 			*error = 2;
-		pi_close(listen_sd);
+		pi_close(sd);
 		return 0;
 	}
 
 	if (error)
 		*error = 0;
-	pi_close(listen_sd);
 	
 	return sd;
 }
