IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 16, 2006, 10:58:49 PM (20 years ago)
Author:
eugene
Message:

major updates to use gprint for buffered / threaded printing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pantasks/SocketOps.c

    r7892 r7917  
    3333  status = inet_aton (hostip, &Address[0].sin_addr);
    3434  if (!status) {
    35     fprintf (stderr, "invalid address\n");
     35    gprint (GP_ERR, "invalid address\n");
    3636    exit (2);
    3737  }
     
    4646  }
    4747
    48   if (DEBUG) fprintf (stderr, "init sock: %d, len: %d\n", InitSocket, length);
     48  if (DEBUG) gprint (GP_ERR, "init sock: %d, len: %d\n", InitSocket, length);
    4949  status = bind (InitSocket, (struct sockaddr *) Address, length);
    5050  if (status == -1) {
     
    7474  fcntl (InitSocket, F_SETFL, !O_NONBLOCK);
    7575
    76   if (DEBUG) fprintf (stderr, "init sock: %d, len: %d\n", InitSocket, length);
     76  if (DEBUG) gprint (GP_ERR, "init sock: %d, len: %d\n", InitSocket, length);
    7777  BindSocket = accept (InitSocket, (struct sockaddr *) &Address_in, &length);
    78   if (DEBUG) fprintf (stderr, "bind sock: %d\n", BindSocket);
     78  if (DEBUG) gprint (GP_ERR, "bind sock: %d\n", BindSocket);
    7979  if (BindSocket == -1) {
    8080    perror ("accept: ");
     
    8484  addr = Address_in.sin_addr.s_addr;
    8585  if (DEBUG) {
    86     fprintf (stderr, "incoming connection from: ");
    87     fprintf (stderr, " %u", (0xff & (addr >>  0)));
    88     fprintf (stderr, ".%u", (0xff & (addr >>  8)));
    89     fprintf (stderr, ".%u", (0xff & (addr >> 16)));
    90     fprintf (stderr, ".%u", (0xff & (addr >> 24)));
    91     fprintf (stderr, "\n");
     86    gprint (GP_ERR, "incoming connection from: ");
     87    gprint (GP_ERR, " %u", (0xff & (addr >>  0)));
     88    gprint (GP_ERR, ".%u", (0xff & (addr >>  8)));
     89    gprint (GP_ERR, ".%u", (0xff & (addr >> 16)));
     90    gprint (GP_ERR, ".%u", (0xff & (addr >> 24)));
     91    gprint (GP_ERR, "\n");
    9292  }
    9393
     
    109109  }
    110110
    111   if (DEBUG) fprintf (stderr, "connection rejected\n");
     111  if (DEBUG) gprint (GP_ERR, "connection rejected\n");
    112112  close (BindSocket);
    113113  return (-1);
    114114
    115115accepted:
    116   if (DEBUG) fprintf (stderr, "connection accepted\n");
     116  if (DEBUG) gprint (GP_ERR, "connection accepted\n");
    117117  fcntl (BindSocket, F_SETFL, O_NONBLOCK);
    118118  return (BindSocket);
     
    135135
    136136  if (DEBUG) {
    137     fprintf (stderr, "trying %s (%s:%d)...", host[0].h_name, hostip, MY_PORT);
     137    gprint (GP_ERR, "trying %s (%s:%d)...", host[0].h_name, hostip, MY_PORT);
    138138  }
    139139
     
    142142  status = inet_aton (hostip, &Address.sin_addr);
    143143  if (!status) {
    144     fprintf (stderr, "invalid address\n");
     144    gprint (GP_ERR, "invalid address\n");
    145145    exit (2);
    146146  }
     
    160160  }
    161161
    162   if (DEBUG) fprintf (stderr, "connected\n");
     162  if (DEBUG) gprint (GP_ERR, "connected\n");
    163163  fcntl (InitSocket, F_SETFL, O_NONBLOCK);
    164164  return (InitSocket);
     
    183183  status = inet_aton (hostip, &Address[0].sin_addr);
    184184  if (!status) {
    185     fprintf (stderr, "invalid address\n");
     185    gprint (GP_ERR, "invalid address\n");
    186186    exit (2);
    187187  }
     
    195195  }
    196196
    197   if (DEBUG) fprintf (stderr, "init sock: %d, len: %d\n", InitSocket, length);
     197  if (DEBUG) gprint (GP_ERR, "init sock: %d, len: %d\n", InitSocket, length);
    198198  status = bind (InitSocket, (struct sockaddr *) Address, length);
    199199  if (status == -1) {
     
    208208  }
    209209
    210   if (DEBUG) fprintf (stderr, "socket listening on %s (%s:%d)\n", host[0].h_name, hostip, MY_PORT);
     210  if (DEBUG) gprint (GP_ERR, "socket listening on %s (%s:%d)\n", host[0].h_name, hostip, MY_PORT);
    211211  return (InitSocket);
    212212}
     
    230230    test &= ((ip4 >=0) && (ip4 < 256));
    231231    if (!test) {
    232       fprintf (stderr, "invalid IP address %s\n", string);
     232      gprint (GP_ERR, "invalid IP address %s\n", string);
    233233      exit (2);
    234234    }
Note: See TracChangeset for help on using the changeset viewer.