Changeset 36740
- Timestamp:
- May 10, 2014, 2:44:40 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140423/Ohana/src
- Files:
-
- 2 edited
-
kapa2/src/CheckPipe.c (modified) (2 diffs)
-
libkapa/src/KapaOpen.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140423/Ohana/src/kapa2/src/CheckPipe.c
r29938 r36740 1 1 # include "Ximage.h" 2 # include <errno.h> 2 3 # define STRCONST(A) ((int)(0x1000000*A[0] + 0x10000*A[1] + 0x100*A[2] + 0x1*A[3])) 3 4 … … 41 42 word[4] = 0; 42 43 switch (status) { 43 case -1: /* no input from pipe: continue */ 44 return (TRUE); 44 case -1: 45 if (errno == EAGAIN) { 46 /* no input from pipe: continue */ 47 return (TRUE); 48 } 49 perror ("exiting due to problem with socket connection in CheckPipe"); 50 return (FALSE); 45 51 break; 46 52 -
branches/eam_branches/ipp-20140423/Ohana/src/libkapa/src/KapaOpen.c
r35761 r36740 218 218 // apparently, I can connect on someone else's port (eg GoogleTalkPlugin) 219 219 // do a simple handshake before we set !NONBLOCK: 220 char line[5]; 221 int Nout = read (InitSocket, line, 4); 222 if (Nout != 4) { 223 if (DEBUG) fprintf (stderr, "connection failed\n"); 224 close (InitSocket); 225 return (-1); 226 } 227 if (strncmp (line, "KAPA", 4)) { 228 if (DEBUG) fprintf (stderr, "connection to the wrong server\n"); 229 close (InitSocket); 230 return (-1); 220 221 // ensure the socket is NONBLOCK first... 222 fcntl (InitSocket, F_SETFL, O_NONBLOCK); 223 224 int Ntry = 0; 225 retry_message: 226 { 227 char line[5]; 228 int Nout = read (InitSocket, line, 4); 229 if ((Nout == -1) && (errno == EAGAIN)) { 230 Ntry ++; 231 if (Ntry > 500) { 232 if (DEBUG) fprintf (stderr, "handshake failure\n"); 233 close (InitSocket); 234 return (-1); 235 } 236 goto retry_message; 237 } 238 if (Nout != 4) { 239 if (DEBUG) fprintf (stderr, "connection failed\n"); 240 close (InitSocket); 241 return (-1); 242 } 243 if (strncmp (line, "KAPA", 4)) { 244 if (DEBUG) fprintf (stderr, "connection to the wrong server\n"); 245 close (InitSocket); 246 return (-1); 247 } 231 248 } 232 249
Note:
See TracChangeset
for help on using the changeset viewer.
