f683064dc6a998206665b484790ef9d561e6c8a7
markd
  Sat Dec 5 22:42:53 2020 -0800
initial conversion to gfServer connection to object

diff --git src/lib/gfNet.c src/lib/gfNet.c
index d6de42d..9259d14 100644
--- src/lib/gfNet.c
+++ src/lib/gfNet.c
@@ -1,33 +1,47 @@
 /* gfNet.c - Network dependent stuff for blat server. */
 
 /* Copyright (C) 2011 The Regents of the University of California 
  * See README in this or parent directory for licensing information. */
 
 #include "common.h"
 #include "errAbort.h"
 #include "genoFind.h"
 #include "net.h"
 
 
-int gfMayConnect(char *hostName, char *portName)
+struct gfConnection *gfMayConnect(char *hostName, char *portName)
 /* Start connection with server or return -1. */
 {
 /* Connect to server. */
 int sd = netConnect(hostName, atoi(portName));
 // if error, sd == -1
-return sd;
+if (sd < 0)
+    return NULL;
+struct gfConnection *conn;
+AllocVar(conn);
+conn->fd = sd;
+return conn;
 }
 
-int gfConnect(char *hostName, char *portName)
+struct gfConnection *gfConnect(char *hostName, char *portName)
 /* Start connection with server. Abort on error. */
 {
 /* Connect to server. */
-int sd = gfMayConnect(hostName, portName);
-if (sd < 0)
+struct gfConnection *conn = gfMayConnect(hostName, portName);
+if (conn == NULL)
     {
     errnoAbort("Sorry, the BLAT/iPCR server seems to be down.  Please try "
                "again later.");
     }
-return sd;
+return conn;
 }
 
+void gfDisconnect(struct gfConnection **pConn)
+/* Disconnect from server */
+{
+if (*pConn != NULL)
+    {
+    close((*pConn)->fd);
+    freez(pConn);
+    }
+}