WIP: connection OK, timer OK
parent
9cdf868755
commit
2a8e9a3707
|
@ -295,6 +295,8 @@ enum ipc_connection_types {
|
|||
* main public functions
|
||||
**/
|
||||
|
||||
struct ipc_error ipc_events_loop (struct ipc_ctx *, struct ipc_event *, int *timer);
|
||||
|
||||
struct ipc_error ipc_server_init (struct ipc_ctx *ctx, const char *sname);
|
||||
struct ipc_error ipc_connection (struct ipc_ctx *ctx, const char *sname);
|
||||
|
||||
|
|
|
@ -11,25 +11,25 @@ int main(int argc, char * argv[], char **env)
|
|||
argc = (int) argc;
|
||||
argv = (char **) argv;
|
||||
|
||||
SECURE_DECLARATION(struct ipc_ctx,ctx);
|
||||
long timer = 10;
|
||||
SECURE_DECLARATION(struct ipc_ctx, ctx);
|
||||
int timer = 10000; // 10 seconds timer
|
||||
|
||||
printf ("func 01 - server init...\n");
|
||||
TEST_IPC_Q(ipc_server_init (&ctx, SERVICE_NAME), EXIT_FAILURE);
|
||||
|
||||
|
||||
printf ("func 01 - server init ok\n");
|
||||
SECURE_DECLARATION(struct ipc_event,event);
|
||||
SECURE_DECLARATION(struct ipc_event, event);
|
||||
|
||||
printf ("func 01 - service polling...\n");
|
||||
|
||||
// listen only for a single client
|
||||
TEST_IPC_Q(ipc_wait_event (&clients, &srv, &event, &timer), EXIT_FAILURE);
|
||||
TEST_IPC_Q(ipc_events_loop (&ctx, &event, &timer), EXIT_FAILURE);
|
||||
|
||||
switch (event.type) {
|
||||
case IPC_EVENT_TYPE_TIMER : {
|
||||
fprintf(stderr, "time up!\n");
|
||||
|
||||
timer = 10;
|
||||
timer = 10000;
|
||||
};
|
||||
break;
|
||||
case IPC_EVENT_TYPE_CONNECTION :
|
||||
|
@ -48,11 +48,11 @@ int main(int argc, char * argv[], char **env)
|
|||
break;
|
||||
}
|
||||
|
||||
printf ("func 01 - closing clients...\n");
|
||||
ipc_connections_free (&clients);
|
||||
|
||||
printf ("func 01 - closing server...\n");
|
||||
TEST_IPC_Q(ipc_server_close(&srv), EXIT_FAILURE);
|
||||
TEST_IPC_Q(ipc_close_all(&ctx), EXIT_FAILURE);
|
||||
|
||||
printf ("func 01 - closing ctx...\n");
|
||||
ipc_connections_free (&ctx);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Reference in New Issue