TetaTricks/code/OSC/listen-osc.c

55 lines
1.3 KiB
C
Raw Normal View History

2024-09-10 23:35:26 +11:00
/* LISTEN OSC */
#include <stdio.h>
2024-09-24 05:53:00 +11:00
#include <unistd.h>
#include <stdlib.h>
2024-09-10 23:35:26 +11:00
#include <lo/lo.h>
#define LOCAL_PORT "9000"
2024-09-24 05:53:00 +11:00
/* ----------------------------------------------------------------- */
void error(int num, const char *msg, const char *path)
{
fprintf(stderr, "liblo server error %d in path %s : %s\n", num, path, msg);
exit(1);
}
/* ----------------------------------------------------------------- */
int handler(const char *path, const char *types, lo_arg ** argv,
int argc, void *data, void *udata)
{
static int event_number = 1;
printf("------ event #%d :\n", event_number++);
printf("\tpath '%s' types '%s' argc %d\n",
path, types, argc);
printf("\tdata %p\n", data);
// if (NULL!=data) printf("\t >%s<\n", data);
printf("\tudata %p\n", udata);
if (NULL!=udata) printf("\t\t>%s<\n", (char *)udata);
return 0;
}
/* ----------------------------------------------------------------- */
char signature[] = "Bourtoulots";
2024-09-10 23:35:26 +11:00
int main(int argc, char *argv[])
{
lo_server_thread st;
2024-09-24 05:53:00 +11:00
int count = 0;
st = lo_server_thread_new(LOCAL_PORT, error);
lo_server_thread_add_method(st, "/demo", "is", handler, signature);
lo_server_thread_start(st);
2024-09-10 23:35:26 +11:00
2024-09-24 05:53:00 +11:00
for (;;) {
fprintf(stderr, "%6d I'm alive\n", count++); sleep(10);
}
2024-09-10 23:35:26 +11:00
return 0;
}