Index: /branches/eam_branches/ipp-20110906/Ohana/src/opihi/include/shell.h
===================================================================
--- /branches/eam_branches/ipp-20110906/Ohana/src/opihi/include/shell.h	(revision 32568)
+++ /branches/eam_branches/ipp-20110906/Ohana/src/opihi/include/shell.h	(revision 32569)
@@ -186,5 +186,5 @@
 int InitServerSocket (SockAddress *Address);
 int WaitServerSocket (int InitSocket, SockAddress *Address);
-int GetClientSocket (char *hostname);
+int GetClientSocket (char *hostname, char *portinfo);
 int InitServerSocket_Named (char *hostname, SockAddress *Address);
 int DefineValidIP (void);
Index: /branches/eam_branches/ipp-20110906/Ohana/src/opihi/lib.shell/SocketOps.c
===================================================================
--- /branches/eam_branches/ipp-20110906/Ohana/src/opihi/lib.shell/SocketOps.c	(revision 32568)
+++ /branches/eam_branches/ipp-20110906/Ohana/src/opihi/lib.shell/SocketOps.c	(revision 32569)
@@ -154,5 +154,5 @@
 }
 
-int GetClientSocket (char *hostname) {
+int GetClientSocket (char *hostname, char *portinfo) {
 
   int i, status, InitSocket, length;
@@ -169,10 +169,39 @@
   }
 
+  // portinfo is a port or port range of the form NN or NN:MM
+  int start = MY_PORT;
+  int stop = start + 10;
+  if (portinfo[0]) {
+      char *endptr;
+      start = strtol (portinfo, &endptr, 0);
+      stop = start + 10; // default range of 10
+      if (!endptr) {
+	  gprint (GP_ERR, "error in port range parsing\n");
+	  exit (20);
+      }
+      if (endptr == portinfo) {
+	  gprint (GP_ERR, "error in port range, must be in form NN:MM or NN\n");
+	  exit (20);
+      }
+      if (*endptr) {
+	  if (*endptr != ":") {
+	      gprint (GP_ERR, "error in port range (wrong range separator, must be in form NN:MM)\n");
+	      exit (20);
+	  }
+	  char *ptr = endptr + 1;
+	  stop = strtol (ptr, &endptr, 0);
+	  if (endptr == ptr)  {
+	      gprint (GP_ERR, "error in port range, must be in form NN:MM or NN\n");
+	      exit (20);
+	  }
+      }
+  }      
+
   if (DEBUG) {
-    gprint (GP_ERR, "trying %s (%s:%d)...", host[0].h_name, hostip, MY_PORT);
+    gprint (GP_ERR, "trying %s (%s:%d)...", host[0].h_name, hostip, start);
   }
 
   Address.sin_family = AF_INET;
-  Address.sin_port   = MY_PORT;
+  Address.sin_port   = start;
 
 retry_client:
@@ -195,5 +224,5 @@
     if (errno == ECONNREFUSED) {
       Address.sin_port ++;
-      if (Address.sin_port > MY_PORT + 10) exit (12);
+      if (Address.sin_port > stop) exit (12);
       goto retry_client;
     }
Index: /branches/eam_branches/ipp-20110906/Ohana/src/opihi/lib.shell/multicommand.c
===================================================================
--- /branches/eam_branches/ipp-20110906/Ohana/src/opihi/lib.shell/multicommand.c	(revision 32568)
+++ /branches/eam_branches/ipp-20110906/Ohana/src/opihi/lib.shell/multicommand.c	(revision 32569)
@@ -13,5 +13,5 @@
 void multicommand_InitServer () {
 
-  char hostname[256], PASSWORD[256];
+  char hostname[256], PASSWORD[256], portinfo[256];
 
   if (server != 0) {
@@ -27,6 +27,10 @@
   }
 
+  /* is a port range defined? otherwise use the default */
+  memset (portinfo, 0, 256);
+  VarConfig ("PANTASKS_SERVER_PORT", "%s", portinfo);
+
   /* attempt to connect to the server */
-  server = GetClientSocket (hostname);
+  server = GetClientSocket (hostname, portinfo);
 
   /* here we can perform the security handshaking */
