The pong client can now select the name of the service.
parent
6b9c65a549
commit
365bf2609c
17
c/pong.c
17
c/pong.c
|
@ -17,7 +17,9 @@ int err(void *ctx, char *msg) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(int argc, char **argv, char** env) {
|
||||||
|
argc = argc;
|
||||||
|
argv = argv;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int servicefd = 0;
|
int servicefd = 0;
|
||||||
char message[MAX_MSG_SIZE];
|
char message[MAX_MSG_SIZE];
|
||||||
|
@ -29,6 +31,15 @@ int main(void) {
|
||||||
int newfd = 0;
|
int newfd = 0;
|
||||||
void *ctx = NULL;
|
void *ctx = NULL;
|
||||||
|
|
||||||
|
char *service = SERVICE;
|
||||||
|
size_t i = 0;
|
||||||
|
while(env[i] != NULL) {
|
||||||
|
if(0 == memcmp(env[i], "SERVICE", strlen("SERVICE"))) {
|
||||||
|
service = env[i] + strlen("SERVICE") + 1;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
printf ("Init context.\n");
|
printf ("Init context.\n");
|
||||||
ret = ipc_context_init (&ctx);
|
ret = ipc_context_init (&ctx);
|
||||||
|
|
||||||
|
@ -37,8 +48,8 @@ int main(void) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("Connect to a 'pong' service.\n");
|
printf ("Connect to a '%s' service.\n", service);
|
||||||
ret = ipc_connect_service (ctx, &servicefd, SERVICE, SERVICE_LEN);
|
ret = ipc_connect_service (ctx, &servicefd, service, strlen(service));
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return err(ctx, "Cannot connect to a service.");
|
return err(ctx, "Cannot connect to a service.");
|
||||||
|
|
Loading…
Reference in New Issue