walter jenner wrote:
hello!
can somebody give me a short explanation, what is done if i add a poll function? Can i use it to check if something has been received at a socket?
Look in s_inter.c and x_net.c of the pd source.... Pd monitors registered file descriptors, which are usually sockets, and calls a user-defined function when something happens, usually data ready to read or incoming connection. The third parameter in the call is a pointer to a data structure associated with the callback function. sys_domicrosleep() in s_inter.c checks for activity on each registered socket by calling select() on each one (but only checks the read set, so errors don't get caught this way). sys_domicrosleep() is quasiperiodically called from m_scheduler(), pd's 'main loop'. In pd, socketreceiver_read() is called from sys_domicrosleep() when something has been received at a socket, so yes, you can use it for that...
It's also possible to do the same thing using timers with clock_new(), as in netclient. Timers seem to have higher priority than pollfunctions in m_scheduler().
Martin
thx a lot! (and sorry for the stupid question, if it is one :) )
best greetings,
walter
PD-dev mailing list PD-dev@iem.at http://lists.puredata.info/listinfo/pd-dev