equal
deleted
inserted
replaced
2 #include <sys/types.h> |
2 #include <sys/types.h> |
3 #include <sys/socket.h> |
3 #include <sys/socket.h> |
4 #include <sys/un.h> |
4 #include <sys/un.h> |
5 #include <errno.h> |
5 #include <errno.h> |
6 #include <stdlib.h> |
6 #include <stdlib.h> |
|
7 #include <stdio.h> |
7 |
8 |
8 #include "main.h" |
9 #include "main.h" |
9 |
10 |
10 extern int server_socket; |
11 extern int server_socket; |
11 |
12 |
61 if (res == 0) |
62 if (res == 0) |
62 return 1; |
63 return 1; |
63 |
64 |
64 /* If error other than "No one listens on the other end"... */ |
65 /* If error other than "No one listens on the other end"... */ |
65 if (!(errno == ENOENT || errno == ECONNREFUSED)) |
66 if (!(errno == ENOENT || errno == ECONNREFUSED)) |
66 return 0; |
67 { |
|
68 perror("c: cannot connect to the server"); |
|
69 exit(-1); |
|
70 } |
67 |
71 |
68 if (errno == ECONNREFUSED) |
72 if (errno == ECONNREFUSED) |
69 unlink("/tmp/prova.socket"); |
73 unlink("/tmp/prova.socket"); |
70 |
74 |
71 /* Try starting the server */ |
75 /* Try starting the server */ |
73 wait_server_up(); |
77 wait_server_up(); |
74 res = try_connect(server_socket); |
78 res = try_connect(server_socket); |
75 |
79 |
76 /* The second time didn't work. Abort. */ |
80 /* The second time didn't work. Abort. */ |
77 if (res == -1) |
81 if (res == -1) |
78 return 0; |
82 { |
|
83 fprintf(stderr, "The server didn't come up.\n"); |
|
84 exit(-1); |
|
85 } |
79 |
86 |
80 printf("Good connection 2\n"); |
|
81 /* Good connection on the second time */ |
87 /* Good connection on the second time */ |
82 return 1; |
88 return 1; |
83 } |
89 } |