Changeset 7917 for trunk/Ohana/src/opihi/pantasks/SocketOps.c
- Timestamp:
- Jul 16, 2006, 10:58:49 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pantasks/SocketOps.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pantasks/SocketOps.c
r7892 r7917 33 33 status = inet_aton (hostip, &Address[0].sin_addr); 34 34 if (!status) { 35 fprintf (stderr, "invalid address\n");35 gprint (GP_ERR, "invalid address\n"); 36 36 exit (2); 37 37 } … … 46 46 } 47 47 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); 49 49 status = bind (InitSocket, (struct sockaddr *) Address, length); 50 50 if (status == -1) { … … 74 74 fcntl (InitSocket, F_SETFL, !O_NONBLOCK); 75 75 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); 77 77 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); 79 79 if (BindSocket == -1) { 80 80 perror ("accept: "); … … 84 84 addr = Address_in.sin_addr.s_addr; 85 85 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"); 92 92 } 93 93 … … 109 109 } 110 110 111 if (DEBUG) fprintf (stderr, "connection rejected\n");111 if (DEBUG) gprint (GP_ERR, "connection rejected\n"); 112 112 close (BindSocket); 113 113 return (-1); 114 114 115 115 accepted: 116 if (DEBUG) fprintf (stderr, "connection accepted\n");116 if (DEBUG) gprint (GP_ERR, "connection accepted\n"); 117 117 fcntl (BindSocket, F_SETFL, O_NONBLOCK); 118 118 return (BindSocket); … … 135 135 136 136 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); 138 138 } 139 139 … … 142 142 status = inet_aton (hostip, &Address.sin_addr); 143 143 if (!status) { 144 fprintf (stderr, "invalid address\n");144 gprint (GP_ERR, "invalid address\n"); 145 145 exit (2); 146 146 } … … 160 160 } 161 161 162 if (DEBUG) fprintf (stderr, "connected\n");162 if (DEBUG) gprint (GP_ERR, "connected\n"); 163 163 fcntl (InitSocket, F_SETFL, O_NONBLOCK); 164 164 return (InitSocket); … … 183 183 status = inet_aton (hostip, &Address[0].sin_addr); 184 184 if (!status) { 185 fprintf (stderr, "invalid address\n");185 gprint (GP_ERR, "invalid address\n"); 186 186 exit (2); 187 187 } … … 195 195 } 196 196 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); 198 198 status = bind (InitSocket, (struct sockaddr *) Address, length); 199 199 if (status == -1) { … … 208 208 } 209 209 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); 211 211 return (InitSocket); 212 212 } … … 230 230 test &= ((ip4 >=0) && (ip4 < 256)); 231 231 if (!test) { 232 fprintf (stderr, "invalid IP address %s\n", string);232 gprint (GP_ERR, "invalid IP address %s\n", string); 233 233 exit (2); 234 234 }
Note:
See TracChangeset
for help on using the changeset viewer.
