# callback for shared library feedhandler

**URL:** <https://forum.kx.com/t/callback-for-shared-library-feedhandler/10682>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [December 15, 2015, 3:56pm UTC](https://forum.kx.com/t/callback-for-shared-library-feedhandler/10682 "2015-12-15T15:56:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshmyzie2](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@joshmyzie2](https://forum.kx.com/u/joshmyzie2)\
**Post date:** [December 15, 2015, 3:56pm UTC](https://forum.kx.com/t/callback-for-shared-library-feedhandler/10682/1 "2015-12-15T15:56:00Z")

</div>

Hello,I trying to write a basic shared library feedhandler, but as a C novice,I’m struggling to understand the use of sd1() with a callback.Say I have a q function defined in my main thread:upd:{insert[`quotes;x]}If I were just sending data to a remote q process, I would usek(-h, (S)“upd”, data, (K)0);But I want to use a single process without a TCP socket. What eventfddo I pass to sd1 and how do I actually get my data from C into my updfunction via a callback?I’m using 32bit linux.Thanks,Josh

---

<div class="post-metadata">

**Author:** ![effbiae](https://avatars.discourse-cdn.com/v4/letter/e/ecae2f/32.png) [@effbiae](https://forum.kx.com/u/effbiae)\
**Post date:** [December 16, 2015, 12:19am UTC](https://forum.kx.com/t/callback-for-shared-library-feedhandler/10682/2 "2015-12-16T00:19:00Z")

</div>

http://code.kx.com/wiki/Cookbook/InterfacingWithC#Callbacks

\> What eventfd&nbsp;do I pass to sd1

create a new one:

&nbsp;d=eventfd(x-\>j,0)

every new file descriptor registered with sd1 needs a callback

\>how do I actually get my data from C into my upd &nbsp;with write/read

the example from the wiki:

k(0,(S)“onCallback”,ki(d),kj(a),(K)0)

instead, use the required callback:

k(0,(S)“upd”,data,(K)0)

when data comes in to c, use write(d), with the address of the data to send to q and trigger the callback

write(x-\>i,&data,4) //4 byte address for l32

the registered callback for d can then use the address of data and call upd&nbsp;

&nbsp;K data;read(d,&data,4);k(0,(S)“upd”,data,(K)0)

hope that helps - untested code above.

jack
