diff --git a/code/OSC/listen-osc.c b/code/OSC/listen-osc.c index f142ded..7d4e5d7 100644 --- a/code/OSC/listen-osc.c +++ b/code/OSC/listen-osc.c @@ -1,15 +1,54 @@ /* LISTEN OSC */ #include +#include +#include + #include #define LOCAL_PORT "9000" -int main(int argc, char *argv[]) +/* ----------------------------------------------------------------- */ +void error(int num, const char *msg, const char *path) { -lo_server_thread st; +fprintf(stderr, "liblo server error %d in path %s : %s\n", num, path, msg); +exit(1); +} +/* ----------------------------------------------------------------- */ -st = lo_server_thread_new(LOCAL_PORT, NULL); +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"; + +int main(int argc, char *argv[]) +{ +lo_server_thread st; +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); + +for (;;) { + fprintf(stderr, "%6d I'm alive\n", count++); sleep(10); + } return 0; } diff --git a/code/OSC/send-osc.c b/code/OSC/send-osc.c index 0968036..fd902ec 100644 --- a/code/OSC/send-osc.c +++ b/code/OSC/send-osc.c @@ -11,8 +11,10 @@ int main(int argc, char *argv[]) lo_address loana; int foo; +fprintf(stderr, "sending to %s:%s\n", REMOTE_HOST, REMOTE_PORT); + loana = lo_address_new(REMOTE_HOST, REMOTE_PORT); -foo = lo_send(loana, "/dev/kmem", "is", 61, "meg, efface !"); -fprintf(stderr, "foo %d\n", foo); +foo = lo_send(loana, "/demo", "is", 61, "meg, efface !"); +fprintf(stderr, "got a %d return code ?\n", foo); return 0; }