[Question] How to pass a value or datas in the callback function of nng_aio_alloc? #1799
-
I have create a server to listen the TCP stream connect, such like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
So typically you set this up with It is possible to cheat and use the input or output parameters for a little bit of data (e.g. (At one point I had an API for attaching other data to AIOs, but in very large scale systems this causes the memory use to bigger than I'd like, and its not strictly necessary with the callback parameter, so I got rid of it.) |
Beta Was this translation helpful? Give feedback.
So typically you set this up with
nng_aio_alloc()
-- the intention is that thevoid *
parameter is one you (the consumer) supply, which can then be passed to the callback (in fact it's the first argument to the callback.)It is possible to cheat and use the input or output parameters for a little bit of data (e.g.
nng_aio_set_input()
with a value of 4 or so, but generally speaking this is risky because the input and output callers are "owned" by the stack in the middle. Usually they only use the first 1 or 2.(At one point I had an API for attaching other data to AIOs, but in very large scale systems this causes the memory use to bigger than I'd like, and its not strictly necessary with t…