Index: /trunk/Ohana/src/opihi/lib.shell/SocketOps.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/SocketOps.c	(revision 8552)
+++ /trunk/Ohana/src/opihi/lib.shell/SocketOps.c	(revision 8553)
@@ -51,4 +51,6 @@
   status = bind (InitSocket, (struct sockaddr *) Address, length);
   if (status == -1) {
+
+# if 0
     fprintf (stderr, "errno: %d\n", errno);
     fprintf (stderr, "EACCES: %d\n", EACCES);
@@ -63,10 +65,14 @@
     fprintf (stderr, "ENOTDIR: %d\n", ENOTDIR);
     fprintf (stderr, "EROFS: %d\n", EROFS);
-
-    Address[0].sin_port ++;
-    if (Address[0].sin_port > MY_PORT + 10) exit (2);
-    fprintf (stderr, "trying next port: %d\n", Address[0].sin_port);
-    goto retry_server;
-
+    fprintf (stderr, "EADDRNOTAVAIL: %d\n", EADDRNOTAVAIL);
+    fprintf (stderr, "EADDRINUSE: %d\n", EADDRINUSE);
+    fprintf (stderr, "ENOSR: %d\n", ENOSR);
+# endif
+
+    if (errno == EADDRINUSE) {
+	Address[0].sin_port ++;
+	if (Address[0].sin_port > MY_PORT + 10) exit (2);
+	goto retry_server;
+    }
     perror ("bind: ");
     exit (2);
@@ -75,4 +81,5 @@
      requires 60sec timeout of the selected socket */
 
+  fprintf (stderr, "bound to port: %d\n", Address[0].sin_port);
   status = listen (InitSocket, 10);
   if (status == -1) {
@@ -183,5 +190,4 @@
       Address.sin_port ++;
       if (Address.sin_port > MY_PORT + 10) exit (2);
-      fprintf (stderr, "trying next port: %d\n", Address.sin_port);
       goto retry_client;
     }
@@ -190,4 +196,5 @@
   }
 
+  if (DEBUG) gprint (GP_ERR, "connected on port: %d\n", Address.sin_port);
   if (DEBUG) gprint (GP_ERR, "connected\n");
   fcntl (InitSocket, F_SETFL, O_NONBLOCK); 
