Grid Community Toolkit
6.2.1607800521 (tag: v6.2.20201212)
|
Net Manager Implementation Tutorial
This example uses functionality from globus_common and globus_net_manager modules, so the headers for those must be included:
#include "globus_common.h" #include "globus_net_manager.h"
To implement a network manager, define a struct globus_net_manager_s containing pointers to the functions in your code that you want invoked during network events, and pass that to globus_net_manager_register(). Applications which use the Context functions or the Globus XIO Net Manager Driver will invoke your functions as network operations occur. For this example (and I would imagine most real implementations), the globus_net_manager_t is statically initialized, like this:
For the examples provided in this library, the globus_net_manager_s is registered during module activation in a globus_extension module. This method makes it easy to use network managers in a shared library environment. This is also a good place to initialize any state that you need to retain between calls to the network manager.
To implement this, do the following:
Finally, the real work of the manager is done in the functions registered in the globus_net_manager_s. For brevity, I'll just include the pre_listen function in this tutorial. This function is passed the task-id associated with the operation, the transport ("tcp", "udp", "udt", etc) used by the network, and whatever attributes are associated with the operation. If we wanted to modify things before they were processed by the network, we could create a modified copy of the attributes in the pre_listen function and return them via the attr_array_out parameter. In this case, we simply print out the information we've received from the network stack.