5.6.3 Example: Dynamic Advertising and Unadvertising of a Service
The following listing shows how to use the
tpadvertise()
function. In this example, a server
called TLR
is programmed to offer only the service
called TLR_INIT
when booted. After some
initialization, TLR_INIT
advertises two services
called DEPOSIT
and WITHDRAW
. Both are
performed by the tlr_funcs
function, and both are
built into the TLR
server.
After advertising DEPOSIT
and
WITHDRAW
, TLR_INIT
unadvertises
itself.
Listing Dynamic Advertising and Unadvertising
extern void tlr_funcs()
.
.
.
if (tpadvertise("DEPOSIT", (tlr_funcs)(TPSVCINFO *)) == -1)
check for errors;
if (tpadvertise("WITHDRAW", (tlr_funcs)(TPSVCINFO *)) == -1)
check for errors;
if (tpunadvertise("TLR_INIT") == -1)
check for errors;
tpreturn(TPSUCCESS, 0, transb->data,0L, 0);
Parent topic: Advertising and Unadvertising Services