IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8553


Ignore:
Timestamp:
Aug 24, 2006, 7:01:55 AM (20 years ago)
Author:
eugene
Message:

better warnings on bind errors

File:
1 edited

Legend:

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

    r8427 r8553  
    5151  status = bind (InitSocket, (struct sockaddr *) Address, length);
    5252  if (status == -1) {
     53
     54# if 0
    5355    fprintf (stderr, "errno: %d\n", errno);
    5456    fprintf (stderr, "EACCES: %d\n", EACCES);
     
    6365    fprintf (stderr, "ENOTDIR: %d\n", ENOTDIR);
    6466    fprintf (stderr, "EROFS: %d\n", EROFS);
    65 
    66     Address[0].sin_port ++;
    67     if (Address[0].sin_port > MY_PORT + 10) exit (2);
    68     fprintf (stderr, "trying next port: %d\n", Address[0].sin_port);
    69     goto retry_server;
    70 
     67    fprintf (stderr, "EADDRNOTAVAIL: %d\n", EADDRNOTAVAIL);
     68    fprintf (stderr, "EADDRINUSE: %d\n", EADDRINUSE);
     69    fprintf (stderr, "ENOSR: %d\n", ENOSR);
     70# endif
     71
     72    if (errno == EADDRINUSE) {
     73        Address[0].sin_port ++;
     74        if (Address[0].sin_port > MY_PORT + 10) exit (2);
     75        goto retry_server;
     76    }
    7177    perror ("bind: ");
    7278    exit (2);
     
    7581     requires 60sec timeout of the selected socket */
    7682
     83  fprintf (stderr, "bound to port: %d\n", Address[0].sin_port);
    7784  status = listen (InitSocket, 10);
    7885  if (status == -1) {
     
    183190      Address.sin_port ++;
    184191      if (Address.sin_port > MY_PORT + 10) exit (2);
    185       fprintf (stderr, "trying next port: %d\n", Address.sin_port);
    186192      goto retry_client;
    187193    }
     
    190196  }
    191197
     198  if (DEBUG) gprint (GP_ERR, "connected on port: %d\n", Address.sin_port);
    192199  if (DEBUG) gprint (GP_ERR, "connected\n");
    193200  fcntl (InitSocket, F_SETFL, O_NONBLOCK);
Note: See TracChangeset for help on using the changeset viewer.