I'm making a program that receives messages from the iPhone App touchOSC. These messages are packaged into UPD datagrams.

There's an open-source library (liblo) that handles the details of receiving the UDP messages and decoding the OSC protocol.

I want to make a c library that's callable from lisp. I was thinking of the following three functions, which capture everything I need for this project:

void init_osc(int port, void(*callback)(char* data));

void osc_done(void);

init_osc() would be called to initialize liblo. It takes a port number, which is the port that liblo should listen on, and a function pointer. When liblo receives an OSC message, it will call this callback, passing it an ordinary c string representation of the message.

This callback will be made in the context of a thread spawned by liblo during the init_osc() call.

The other function osc_done() would be called when the program is exiting, to do any cleanup the library needs.


Now to my question: Will this work? Is it possible for this liblo thread to call into my lisp program, passing a string?

If no, what's a better way to do this?

If yes, what syntax do I use to set up the callback?


Thanks,

Neil