ttUserDnsUpdateCBFuncPtr
Table of Contents >> Application Reference >> Dynamic DNS Update
| #include <trsocket.h> |
| void ttUserDnsUpdateCBFuncPtr | ( |
| ttDnsUpdateHandle dnsUpdateHandle, | |
| void * userDataPtr, | |
| int eventId | |
| ); |
Function Description
This is a prototype for a callback function that you can provide. This is only for use in non-blocking mode (see tfDnsInit()). Non-blocking mode requires that you call tfDnsUpdateExecute() periodically while the the DNS update process is in progress. If you want to know when you need to call tfDnsUpdateExecute(), you can receive event notification by calling tfDnsUpdateSetCallback() to set a callback function with the prototype shown on this page.You may call tfDnsUpdateExecute() from within your callback function, but doing so would place a burden on the context in which your function is called, namely the receive task or timer task. One of the main reasons for choosing non-block mode is so that you can do the processing at a lower priority.
The following example shows how you might use the callback function to do simple event synchronization:
void myDnsUpdate(struct sockaddr_storage * serverAddrPtr) { ttDnsUpdateHandle dnsUpdateHandle; int errorCode; /* Initialize Treck DNS */ errorCode = tfDnsInit(TM_BLOCKING_OFF); assert(errorCode == TM_ENOERROR); ... /* Start a UDP session */ dnsUpdateHandle = tfDnsUpdateOpen(serverAddrPtr, 0, &errorCode); assert(dnsUpdateHandle != TM_DNS_UPDATE_INVALID_HANDLE); ... /* Notify me of events */ errorCode = tfDnsUpdateSetCallback(dnsUpdateHandle, myDnsUpdateCB, NULL); assert(errorCode == TM_ENOERROR); ... /* Send the request and wait for the reply */ errorCode = tfDnsUpdateSend(dnsUpdateHandle); while (errorCode == TM_EWOULDBLOCK) { KernelSignalWait(myDnsUpdateSemaphore); errorCode = tfDnsUpdateExecute(dnsUpdateHandle); } assert(errorCode == TM_ENOERROR); ... /* End of session */ errorCode = tfDnsUpdateClose(dnsUpdateHandle); assert(errorCode == TM_ENOERROR); } /* * Callback function to receive notification of DNS update events. */ void myDnsUpdateCB( ttDnsUpdateHandle dnsUpdateHandle, void * userDataPtr, int eventId) { KernelSignal(myDnsUpdateSemaphore); }
Parameters
- dnsUpdateHandle
- The DNS update descriptor handle that you specified when you called tfDnsUpdateSetCallback().
- userDataPtr
- A pointer that you specified when you called tfDnsUpdateSetCallback().
- eventId
- The reason for the event: TM_DNS_UPDATE_EVENT_SOCKET for a socket event (data received, connection completed, socket error), or TM_DNS_UPDATE_EVENT_TIMER for a timer event (UDP retransmission required or the server has not responded within the required time limit).
Table of Contents >> Application Reference >> Dynamic DNS Update