User`s guide

126
K
A
DAK
KwikNet Low Level Services
Processing Received UDP Datagrams
Your UDP callback function executes in the context of the KwikNet Task. Your function
must not initiate any operation which would force the KwikNet Task to be blocked waiting
for some event.
In most multitasking applications, it is recommended that your UDP callback function
pass the UDP message descriptor to some other application task for processing. Often
that task will be the same task that opened the UDP channel and initiated the
conversation in the first place. Field xudpm_node in the UDP message descriptor is a
KwikNet list node that your application can use to attach the descriptor to a list managed
using the private KwikNet List Manager services (see procedures kn_lmxxxxx() in source
file KN_LMGR.C).
Even in single threaded systems, your UDP callback function should pass the UDP
message descriptor to your App-Task for processing.
Note that your task has access to the copy of your application parameter located in field
xudpm_user in the UDP message descriptor. Note that field xudpm_channel contains the
UDP channel ID, the user handle acquired when you called kn_udpopen().
When your task finishes processing the UDP datagram, it must call KwikNet procedure
kn_udpfree() to release the UDP message descriptor and free the associated data
storage for reuse by KwikNet.
Broadcast UDP Datagrams
A broadcast UDP datagram is a message directed to IP address 255.255.255.255. You
can send and receive broadcast UDP datagrams on a UDP channel. When a broadcast
UDP datagram is received, it is delivered to the first UDP channel which KwikNet can find
with a matching local port number.
UDP Echo Requests
A UDP datagram directed to well known port 7 is called a UDP Echo Request. Your
application can handle UDP echo requests by opening a UDP channel on port 7. Any
UDP datagram received for port 7 will be passed to your UDP callback function.