IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 27, 2011, 9:59:48 AM (15 years ago)
Author:
eugene
Message:

adding port options to pantasks server

Location:
branches/eam_branches/ipp-20110906/Ohana/src/opihi
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110906/Ohana/src/opihi/include/shell.h

    r31667 r32569  
    186186int InitServerSocket (SockAddress *Address);
    187187int WaitServerSocket (int InitSocket, SockAddress *Address);
    188 int GetClientSocket (char *hostname);
     188int GetClientSocket (char *hostname, char *portinfo);
    189189int InitServerSocket_Named (char *hostname, SockAddress *Address);
    190190int DefineValidIP (void);
  • branches/eam_branches/ipp-20110906/Ohana/src/opihi/lib.shell/SocketOps.c

    r23530 r32569  
    154154}
    155155
    156 int GetClientSocket (char *hostname) {
     156int GetClientSocket (char *hostname, char *portinfo) {
    157157
    158158  int i, status, InitSocket, length;
     
    169169  }
    170170
     171  // portinfo is a port or port range of the form NN or NN:MM
     172  int start = MY_PORT;
     173  int stop = start + 10;
     174  if (portinfo[0]) {
     175      char *endptr;
     176      start = strtol (portinfo, &endptr, 0);
     177      stop = start + 10; // default range of 10
     178      if (!endptr) {
     179          gprint (GP_ERR, "error in port range parsing\n");
     180          exit (20);
     181      }
     182      if (endptr == portinfo) {
     183          gprint (GP_ERR, "error in port range, must be in form NN:MM or NN\n");
     184          exit (20);
     185      }
     186      if (*endptr) {
     187          if (*endptr != ":") {
     188              gprint (GP_ERR, "error in port range (wrong range separator, must be in form NN:MM)\n");
     189              exit (20);
     190          }
     191          char *ptr = endptr + 1;
     192          stop = strtol (ptr, &endptr, 0);
     193          if (endptr == ptr)  {
     194              gprint (GP_ERR, "error in port range, must be in form NN:MM or NN\n");
     195              exit (20);
     196          }
     197      }
     198  }     
     199
    171200  if (DEBUG) {
    172     gprint (GP_ERR, "trying %s (%s:%d)...", host[0].h_name, hostip, MY_PORT);
     201    gprint (GP_ERR, "trying %s (%s:%d)...", host[0].h_name, hostip, start);
    173202  }
    174203
    175204  Address.sin_family = AF_INET;
    176   Address.sin_port   = MY_PORT;
     205  Address.sin_port   = start;
    177206
    178207retry_client:
     
    195224    if (errno == ECONNREFUSED) {
    196225      Address.sin_port ++;
    197       if (Address.sin_port > MY_PORT + 10) exit (12);
     226      if (Address.sin_port > stop) exit (12);
    198227      goto retry_client;
    199228    }
  • branches/eam_branches/ipp-20110906/Ohana/src/opihi/lib.shell/multicommand.c

    r27435 r32569  
    1313void multicommand_InitServer () {
    1414
    15   char hostname[256], PASSWORD[256];
     15  char hostname[256], PASSWORD[256], portinfo[256];
    1616
    1717  if (server != 0) {
     
    2727  }
    2828
     29  /* is a port range defined? otherwise use the default */
     30  memset (portinfo, 0, 256);
     31  VarConfig ("PANTASKS_SERVER_PORT", "%s", portinfo);
     32
    2933  /* attempt to connect to the server */
    30   server = GetClientSocket (hostname);
     34  server = GetClientSocket (hostname, portinfo);
    3135
    3236  /* here we can perform the security handshaking */
Note: See TracChangeset for help on using the changeset viewer.