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