Polling for information allows you to receive a one-time snapshot of information. Polling can be done at regular time intervals by issuing poll requests repeatedly. All polling of a project goes through RTserver. Typically, a request for particular information is sent to RTserver, then RTserver retrieves the information from its internal tables, from other RTservers, or from RTclients and sends it back to the requesting program.
The type of information polled about projects, RTservers, RTclients, and subjects, is shown in the table. The table lists the entity from where the information is available (RTclient, RTserver, subject), a brief description of the information available, whether the information can be watched as well as polled, and the final column shows the TipcMon* API call that initiates the polling and then the monitoring message type returned. The prefix T_MT_ is omitted from the message type for the sake of brevity.
Some information that can be polled can also be watched. See Watching for more details on watching information.
To initiate a polling request in your program, call an API function, TipcMonType
Poll, where Type
is the kind of information you wish to request. For example, a call to TipcMonSubjectSubscribePoll initiates a poll for information about which RTclients are subscribing to a specified subject, and a call to TipcMonClientTimePoll initiates a poll for time information about an RTclient.
Calling a TipcMonType
Poll function causes a message of type MON_TYPE
_POLL_CALL to be sent to RTserver, where TYPE
is the kind of information being requested. This TYPE
is very similar to the Type
used in the name of the API function as shown in these examples:
RTserver may already hold the information requested, RTserver may need to ask other RTservers for the information, or RTserver may need to forward the message to one or more RTclients to retrieve the information. If RTserver holds the information, the response should come back quickly. For example, you can poll for the names of all projects that RTserver knows about.
If the RTclient has the information, the response may or may not come back quickly depending on how busy the RTclient is. For example, you can poll for information about an RTclient’s message buffers. If RTserver must gather the requested information from an RTclient, the RTclient must read and process messages through calls to TipcSrvMainLoop, TipcSrvMsgNext, TipcMsgSearch, or TipcMsgSearchType in order for the poll request to be returned.
RTserver returns requested information in a MON_TYPE
_POLL_RESULT message, where TYPE
matches the TYPE
in the MON_TYPE
_POLL_CALL that initiated the request. The message types are in pairs of MON_TYPE_
POLL_CALL and MON_TYPE_
POLL_RESULT as shown in these examples:
A complete listing and description of these message types are described in Polling Message Types. The message grammars for all monitoring message types are described in Monitoring Message Types.
When the results of a poll are returned in a MON_TYPE
_POLL_RESULT message, the message is processed in one of these two ways:
Typically, after performing a one-time poll for information, the program blocks and waits for the result before continuing. For example, you can poll to find out if any RTclients are subscribing to a subject prior to sending a message. When polling often, or watching for information, using callbacks is usually the preferred method, as it is unclear when the monitoring results may be returned to the program. The sections that follow present examples of how to process poll results using both methods.
This example shows how to issue a poll request and then use TipcMsgSearchType to block and search for the results (for up to 10 seconds):
T_IPC_MT mt; T_IPC_MSG msg; T_STR *project_names; T_INT4 num_project_names;/* send the poll request out to RTserver */
if (!TipcMonProjectNamesPoll()) {/* error */
} mt = TipcMtLookupByNum(T_MT_MON_PROJECT_NAMES_POLL_RESULT); if (mt == NULL) {/* error */
}/* wait up to 10 seconds for the poll result */
msg = TipcSrvMsgSearchType(10.0, mt); if (msg == NULL) {/* error */
}/* access the fields of the returned message */
if (!TipcMsgSetCurrent(msg, 0)) {/* error */
} if (!TipcMsgNextStrArray(msg, &project_names, &num_project_names)) {/* error */
}/* do whatever here with the poll results */
/* clean up */
if (!TipcMsgDestroy(msg)) {/* error */
}
This example shows how to use an RTclient message process callback (created with TipcSrvProcessCbCreate) to process the message containing the poll result:
/*..process_project_names_poll - callback to process
MON_PROJECT_NAMES_POLL_RESULT */
static void T_ENTRY process_project_names_poll( T_IPC_CONN conn, T_IPC_CONN_PROCESS_CB_DATA data, T_CB_ARG arg) { T_STR *project_names; T_INT4 num_project_names;/* access the fields of the returned message */
if (!TipcMsgSetCurrent(data->msg, 0)) {/* error */
} if (!TipcMsgNextStrArray(data->msg, &project_names, &num_project_names)) {/* error */
}/* do whatever here with poll results */
}/* process_project_names_poll */
/* =============================================================== */
/* ... later, in main program */
T_IPC_MT mt;/* create callback to process MON_PROJECT_NAMES poll results */
mt = TipcMtLookupByNum(T_MT_MON_PROJECT_NAMES_POLL_RESULT); if (mt == NULL) {/* error */
} if (TipcSrvProcessCbCreate(mt, process_project_names_poll, NULL) == NULL){/* error */
}/* send the poll request out to RTserver */
if (!TipcMonProjectNamesPoll()) {/* error */
}/* TipcSrvMainLoop may be called here */
This section contains a complete listing of each polling message type. For each message pair (MON_TYPE
_POLL_CALL and MON_TYPE
_POLL_RESULT), a description of the type of information, the API function, and where the information is collected from is shown. Information gathered from RTserver should come back quickly, while information gathered from RTclient may or may not.
The T_MT_ prefix is omitted from the name of each message type for the sake of brevity.
The MON_CLIENT_BUFFER_POLL_CALL message type is used to request message-related buffer information about one or more RTclients in a project. The polled RTclients respond by sending back MON_CLIENT_BUFFER_POLL_RESULT messages.
API Function: TipcMonClientBufferPoll
Message Initiated: MON_CLIENT_BUFFER_POLL_CALL
Message Returned: MON_CLIENT_BUFFER_POLL_RESULT
Info Gathered From: RTclient
The MON_CLIENT_CB_POLL_CALL message type is used to request callback information about one or more RTclients in a project. The polled RTclients respond by sending back a MON_CLIENT_CB_POLL_RESULT message.
API Function: TipcMonClientCbPoll
Message Initiated: MON_CLIENT_CB_POLL_CALL
Message Returned: MON_CLIENT_CB_POLL_RESULT
Info Gathered From: RTclient
The MON_CLIENT_CPU_POLL_CALL message type is used to request CPU usage information about one or more RTclients in a project. The polled RTclients respond by sending back MON_CLIENT_CPU_POLL_RESULT messages.
API Function: TipcMonClientCpuPoll
Message Initiated: MON_CLIENT_CPU_POLL_CALL
Message Returned: MON_CLIENT_CPU_POLL_RESULT
Info Gathered From: RTclient
The MON_CLIENT_EXT_POLL_CALL message type is used to request RTclient extension data. Extension data is information created by an RTclient. You must use the TipcMonExt* APIs to define and update the fields of an RTclient’s MON_CLIENT_EXT_POLL_RESULT message for extension data. The polled RTclients respond by sending back MON_CLIENT_EXT_POLL_RESULT messages.
API Function: TipcMonClientExtPoll
Message Initiated: MON_CLIENT_EXT_POLL_CALL
Message Returned: MON_CLIENT_EXT_POLL_RESULT
Info Gathered From: RTclient
The MON_CLIENT_GENERAL_POLL_CALL message type is used to request general information about one or more RTclients in a project. The polled RTclients respond by sending back a MON_CLIENT_GENERAL_POLL_RESULT message.
API Function: TipcMonClientGeneralPoll
Message Initiated: MON_CLIENT_GENERAL_POLL_CALL
Message Returned: MON_CLIENT_GENERAL_POLL_RESULT
Info Gathered From: RTclient
The MON_CLIENT_INFO_POLL_CALL message type is used to request general information, including CPU usage, about one or more RTclients in a project. The polled RTclients respond by sending back MON_CLIENT_INFO_POLL_RESULT messages.
API Function: TipcMonClientInfoPoll
Message Initiated: MON_CLIENT_INFO_POLL_CALL
Message Returned: MON_CLIENT_INFO_POLL_RESULT
Info Gathered From: RTclient
The MON_CLIENT_MSG_TRAFFIC_POLL_CALL message type is used to request message traffic information about one or more RTclients in a project. The polled RTclients respond by sending back a MON_CLIENT_MSG_TRAFFIC_POLL_RESULT message.
API Function: TipcMonClientMsgTrafficPoll
Message Initiated: MON_CLIENT_MSG_TRAFFIC_POLL_CALL
Message Returned: MON_CLIENT_MSG_TRAFFIC_POLL_RESULT
Info Gathered From: RTclient
The MON_CLIENT_MSG_TYPE_EX_POLL_CALL message type is used to request message type information about one or more RTclients in a project. The polled RTclients respond by sending back a MON_CLIENT_MSG_TYPE_POLL_EX_RESULT message.
API Function: TipcMonClientMsgTypeExPoll
Message Initiated: MON_CLIENT_MSG_TYPE_EX_POLL_CALL
Message Returned: MON_CLIENT_MSG_TYPE_EX_POLL_RESULT
Info Gathered From: RTclient
The MON_CLIENT_NAMES_NUM_POLL_CALL message type is used to request the number of RTclients in an RTserver cloud. The polled RTclients respond by sending back MON_CLIENT_NAMES_NUM_POLL_RESULT messages.
API Function: TipcMonClientNamesNumPoll
Message Initiated: MON_CLIENT_NAMES_NUM_POLL_CALL
Message Returned: MON_CLIENT_NAMES_NUM_POLL_RESULT
Info Gathered From: RTserver
The MON_CLIENT_NAMES_POLL_CALL message type is used to request the running RTclient names in the current project. RTserver responds by sending back a MON_CLIENT_NAMES_POLL_RESULT message.
API Function: TipcMonClientNamesPoll
Message Initiated: MON_CLIENT_NAMES_POLL_CALL
Message Returned: MON_CLIENT_NAMES_POLL_RESULT
Info Gathered From: RTserver
The MON_CLIENT_OPTION_POLL_CALL message type is used to request option information about one or more RTclients in a project. The polled RTclients respond by sending back a MON_CLIENT_OPTION_POLL_RESULT message.
API Function: TipcMonClientOptionPoll
Message Initiated: MON_CLIENT_OPTION_POLL_CALL
Message Returned: MON_CLIENT_OPTION_POLL_RESULT
Info Gathered From: RTclient
The MON_CLIENT_SUBJECT_EX_POLL_CALL message type is used to request subject information about one or more RTclients in a project. The polled RTclients respond by sending back a MON_CLIENT_SUBJECT_EX_POLL_RESULT message.
API Function: TipcMonClientSubjectExPoll
Message Initiated: MON_CLIENT_SUBJECT_EX_POLL_CALL
Message Returned: MON_CLIENT_SUBJECT_EX_POLL_RESULT
Info Gathered From: RTclient
The MON_CLIENT_SUBSCRIBE_NUM_POLL_CALL message type is used to request the number of subjects subscribed to by one or more RTclients in a project. The polled RTclients respond by sending back MON_CLIENT_SUBSCRIBE_NUM_POLL_RESULT messages.
API Function: TipcMonClientSubscribeNumPoll
Message Initiated: MON_CLIENT_SUBSCRIBE_NUM_POLL_CALL
Message Returned: MON_CLIENT_SUBSCRIBE_NUM_POLL_RESULT
Info Gathered From: RTserver
The MON_CLIENT_SUBSCRIBE_POLL_CALL message type is used to request the current subjects to which one or more RTclients in a project are subscribing. RTserver responds by sending back a MON_CLIENT_SUBSCRIBE_POLL_RESULT message for each RTclient specified.
API Function: TipcMonClientSubscribePoll
Message Initiated: MON_CLIENT_SUBSCRIBE_POLL_CALL
Message Returned: MON_CLIENT_SUBSCRIBE_POLL_RESULT
Info Gathered From: RTserver
The MON_CLIENT_TIME_POLL_CALL message type is used to request time information about one or more RTclients in a project. The polled RTclients respond by sending back MON_CLIENT_TIME_POLL_RESULT messages.
API Function: TipcMonClientTimePoll
Message Initiated: MON_CLIENT_TIME_POLL_CALL
Message Returned: MON_CLIENT_TIME_POLL_RESULT
Info Gathered From: RTclient
The MON_CLIENT_VERSION_POLL_CALL message type is used to request client version of one or more RTclients in a project. The polled RTclients respond by sending back MON_CLIENT_VERSION_POLL_RESULT messages.
API Function: TipcMonClientVersionPoll
Message Initiated: MON_CLIENT_VERSION_POLL_CALL
Message Returned: MON_CLIENT_VERSION_POLL_RESULT
Info Gathered From: RTclient
The MON_PROJECT_NAMES_POLL_CALL message type is used to request the current project names from RTserver. RTserver responds by sending back a MON_PROJECT_NAMES_POLL_RESULT message.
API Function: TipcMonProjectNamesPoll
Message Initiated: MON_PROJECT_NAMES_POLL_CALL
Message Returned: MON_PROJECT_NAMES_POLL_RESULT
Info Gathered From: RTserver
The MON_SERVER_BUFFER_POLL_CALL message type is used to request message-related buffer information about one or more RTservers in an RTserver group. The polled RTservers respond by sending back a MON_SERVER_BUFFER_POLL_RESULT message.
API Function: TipcMonServerBufferPoll
Message Initiated: MON_SERVER_BUFFER_POLL_CALL
Message Returned: MON_SERVER_BUFFER_POLL_RESULT
Info Gathered From: RTserver
The MON_SERVER_CONN_POLL_CALL message type is used to request connection information about one or more RTservers in an RTserver group. The polled RTservers respond by sending back a MON_SERVER_CONN_POLL_RESULT message.
API Function: TipcMonServerConnPoll
Message Initiated: MON_SERVER_CONN_POLL_CALL
Message Returned: MON_SERVER_CONN_POLL_RESULT
Info Gathered From: RTserver
The MON_SERVER_CPU_POLL_CALL message type is used to request CPU usage information about one or more RTservers in a project. The polled RTclients respond by sending back MON_SERVER_CPU_POLL_RESULT messages.
API Function: TipcMonServerCpuPoll
Message Initiated: MON_SERVER_CPU_POLL_CALL
Message Returned: MON_SERVER_CPU_POLL_RESULT
Info Gathered From: RTserver
The MON_SERVER_GENERAL_POLL_CALL message type is used to request general process information about one or more RTservers in an RTserver group. The polled RTservers respond by sending back a MON_SERVER_GENERAL_POLL_RESULT message.
API Function: TipcMonServerGeneralPoll
Message Initiated: MON_SERVER_GENERAL_POLL_CALL
Message Returned: MON_SERVER_GENERAL_POLL_RESULT
Info Gathered From: RTserver
The MON_SERVER_MSG_TRAFFIC_EX_POLL_CALL message type is used to request message traffic information about one or more RTservers in an RTserver group. The polled RTservers respond by sending back a MON_SERVER_MSG_TRAFFIC_EX_POLL_RESULT message.
API Function: TipcMonServerMsgTrafficExPoll
Message Initiated: MON_SERVER_MSG_TRAFFIC_EX_POLL_CALL
Message Returned: MON_SERVER_MSG_TRAFFIC_EX_POLL_RESULT
Info Gathered From: RTserver
The MON_SERVER_NAMES_POLL_CALL message type is used to request the running RTserver names. RTserver responds by sending back a MON_SERVER_NAMES_POLL_RESULT message.
API Function: TipcMonServerNamesPoll
Message Initiated: MON_SERVER_NAMES_POLL_CALL
Message Returned: MON_SERVER_NAMES_POLL_RESULT
Info Gathered From: RTserver
The MON_SERVER_OPTION_POLL_CALL message type is used to request option information about one or more RTservers in an RTserver group. The polled RTservers respond by sending back a MON_SERVER_OPTION_POLL_RESULT message.
API Function: TipcMonServerOptionPoll
Message Initiated: MON_SERVER_OPTION_POLL_CALL
Message Returned: MON_SERVER_OPTION_POLL_RESULT
Info Gathered From: RTserver
The MON_SERVER_ROUTE_POLL_CALL message type is used to request route information about one or more RTservers in an RTserver group. The polled RTservers respond by sending back a MON_SERVER_ROUTE_POLL_RESULT message.
API Function: TipcMonServerRoutePoll
Message Initiated: MON_SERVER_ROUTE_POLL_CALL
Message Returned: MON_SERVER_ROUTE_POLL_RESULT
Info Gathered From: RTserver
The MON_SERVER_START_TIME_POLL_CALL message type is used to request start time and elapsed time information about one or more RTservers in an RTserver group. The polled RTservers respond by sending back MON_SERVER_START_TIME_POLL_RESULT messages.
API Function: TipcMonStartServerTimePoll
Message Initiated: MON_SERVER_START_TIME_POLL_CALL
Message Returned: MON_SERVER_START_TIME_POLL_RESULT
Info Gathered From: RTserver
The MON_SERVER_TIME_POLL_CALL message type is used to request time information (wall time and CPU timed used) about one or more RTservers in an RTserver group. The polled RTservers respond by sending back a MON_SERVER_TIME_POLL_RESULT message.
API Function: TipcMonServerTimePoll
Message Initiated: MON_SERVER_TIME_POLL_CALL
Message Returned: MON_SERVER_TIME_POLL_RESULT
Info Gathered From: RTserver
The MON_SERVER_VERSION_POLL_CALL message type is used to request server version of one or more RTservers in a project. The polled RTservers respond by sending back MON_SERVER_VERSION_POLL_RESULT messages.
API Function: TipcMonServerVersionPoll
Message Initiated: MON_SERVER_VERSION_POLL_CALL
Message Returned: MON_SERVER_VERSION_POLL_RESULT
Info Gathered From: RTserver
The MON_SUBJECT_NAMES_POLL_CALL message type is used to request the current subject names in the current project. RTserver responds by sending back a MON_SUBJECT_NAMES_POLL_RESULT message.
API Function: TipcMonSubjectNamesPoll
Message Initiated: MON_SUBJECT_NAMES_POLL_CALL
Message Returned: MON_SUBJECT_NAMES_POLL_RESULT
Info Gathered From: RTserver
The MON_SUBJECT_SUBSCRIBE_POLL_CALL message type is used to request the current RTclients that are subscribing to a specified subject or all subjects. RTserver responds by sending back a MON_SUBJECT_SUBSCRIBE_POLL_RESULT message for each subject.
API Function: TipcMonSubjectSubscribePoll
Message Initiated: MON_SUBJECT_SUBSCRIBE_POLL_CALL
Message Returned: MON_SUBJECT_SUBSCRIBE_POLL_RESULT
Info Gathered From: RTserver
The following is a complete C source example of a program that continues to poll for message traffic information at a regular interval, where the interval (in seconds) is one of the command line arguments passed in to the program.
The source code files for this example are located in these directories:
The online source files have additional #ifdefs to provide C++ support. These #ifdefs are not shown to simplify the example.
/* ------------------------------------------------------------------ polltraf.c USAGE polltraf <project> <unique_subject> <poll_interval> This program gathers message traffic information on the RTclient specified in the command line arg <unique_subject> in project <project>. The info is polled for on a regular interval as specified in <poll_interval>. You can gather message traffic info on all clients in a project by specifying "/..." for <unique_subject>. <poll_interval> is always specified in seconds (as an integer). Sample usage: polltraf tank my_ie 10 polltraf tank /... 30 ------------------------------------------------------------------ */ #include <rtworks/ipc.h> /* ================================================================ */ /*..cb_default - default callback */ static void T_ENTRY cb_default ( T_IPC_CONN conn, T_IPC_CONN_DEFAULT_CB_DATA data, T_CB_ARG arg ) { if (!TipcMsgPrintError(data->msg)) { TutOut("Could not print message: error <%s>.\n", TutErrStrGet()); } } /* cb_default */ /* =============================================================== */ /*..process_traffic_poll - callback to process a MON_CLIENT_MSG_TRAFFIC_POLL_RESULT message */ static void T_ENTRY process_traffic_poll ( T_IPC_CONN conn, T_IPC_CONN_PROCESS_CB_DATA data, T_CB_ARG arg ) { T_IPC_MSG msg = data->msg; T_STR client_name; T_INT4 total_msg_recv_4; T_INT4 total_msg_send_4; T_INT4 total_byte_recv_4; T_INT4 total_byte_send_4; T_INT8 total_msg_recv_8; T_INT8 total_msg_send_8; T_INT8 total_byte_recv_8; T_INT8 total_byte_send_8; /* Set current field */ if (!TipcMsgSetCurrent(msg, 0)) { TutOut("Could not set current field of message: error <%s>.\n", TutErrStrGet()); return; } /* Get the fields from the message */ if (!TipcMsgRead(data->msg, T_IPC_FT_STR, &client_name, T_IPC_FT_INT4, &total_msg_recv_4, T_IPC_FT_INT4, &total_msg_send_4, T_IPC_FT_INT4, &total_byte_recv_4, T_IPC_FT_INT4, &total_byte_send_4, NULL)) { TutOut("Unable to access message traffic message: error <%s>.\n", TutErrStrGet()); return; } TutOut("Summary of message traffic for RTclient <%s>\n", client_name); if (TipcMsgRead(data->msg, T_IPC_FT_INT8, &total_msg_recv_8, T_IPC_FT_INT8, &total_msg_send_8, T_IPC_FT_INT8, &total_byte_recv_8, T_IPC_FT_INT8, &total_byte_send_8, NULL)) { /* Print out the new information received */ TutOut(" (Received 64-bit data)\n"); TutOut(" Total messages received = " T_INT8_SPEC "\n", total_msg_recv_8); TutOut(" Total messages sent = " T_INT8_SPEC "\n", total_msg_send_8); TutOut(" Total bytes received = " T_INT8_SPEC "\n", total_byte_recv_8); TutOut(" Total bytes sent = " T_INT8_SPEC "\n", total_byte_recv_8); } else { /* Print out the new information received */ TutOut(" (Received 32-bit data)\n"); TutOut(" Total messages received = " T_INT4_SPEC "\n", total_msg_recv_4); TutOut(" Total messages sent = " T_INT4_SPEC "\n", total_msg_send_4); TutOut(" Total bytes received = " T_INT4_SPEC "\n", total_byte_recv_4); TutOut(" Total bytes sent = " T_INT4_SPEC "\n", total_byte_recv_4); } TutOut("======================================================\n") ; } /* process_traffic_poll */ /* =============================================================== */ int main ( int argc, char **argv ) { T_STR project_name; T_STR unique_subject; T_REAL8 poll_interval; T_IPC_MT mt; T_OPTION option; /* Check the command line arguments */ if (argc != 4) { TutOut("Usage: polltraf <project> <unique_subject> "); TutOut("<poll_interval>\n"); TutExit(T_EXIT_FAILURE); } /* Save pointers to command line arguments */ project_name = argv[1]; unique_subject = argv[2]; poll_interval = atof(argv[3]); /* Check that the polling interval is greater than zero */ if (poll_interval <= 0.0) { TutOut("Poll_Interval must be greater than zero.\n"); TutExit(T_EXIT_FAILURE); } TutOut("Polling RTclient <%s> in project <%s> ", unique_subject, project_name); TutOut("every <%g> seconds...\n", poll_interval); /* Set the project name */ option = TutOptionLookup("project"); if (option == NULL) { TutOut("Could not look up option <project>: error <%s>.\n", TutErrStrGet()); TutExit(T_EXIT_FAILURE); } if (!TutOptionSetEnum(option, project_name)) { TutOut("Could not set option <project>: error <%s>.\n", TutErrStrGet()); TutExit(T_EXIT_FAILURE); } /* Connect to RTserver */ if (!TipcSrvCreate(T_IPC_SRV_CONN_FULL)) { TutOut("Could not connect to RTserver: error <%s>.\n", TutErrStrGet()); TutExit(T_EXIT_FAILURE); } /* Create callback to process CLIENT_MSG_TRAFFIC poll results */ mt = TipcMtLookupByNum(T_MT_MON_CLIENT_MSG_TRAFFIC_POLL_RESULT); if (mt == NULL) { TutOut("Could not look up message type "); TutOut("MON_CLIENT_MSG_TRAFFIC_POLL_RESULT: error <%s>.\n", TutErrStrGet()); TutExit(T_EXIT_FAILURE); } if (TipcSrvProcessCbCreate(mt, process_traffic_poll, NULL) == NULL){ TutOut("Could not set up callback to process "); TutOut("MON_CLIENT_MSG_POLL_RESULT: error <%s>.\n", TutErrStrGet()); TutExit(T_EXIT_FAILURE); } /* Create default callback to receive unwanted message types */ if (TipcSrvDefaultCbCreate(cb_default, NULL) == NULL) { TutOut("Could not create default callback: error <%s>.\n", TutErrStrGet()); } /* Read and process poll results every "poll_interval" seconds */ while (1) { TutOut("==> Polling RTclient <%s> for message traffic info...\n", unique_subject); /* Initiate poll for message traffic info about an RTclient */ if (!TipcMonClientMsgTrafficPoll(unique_subject)) { TutOut("Unable to poll for message traffic for RTclient <%s>.\n", unique_subject); TutOut(" error <%s>.\n", TutErrStrGet()); } /* Process the poll results which arrive */ if (!TipcSrvMainLoop(poll_interval)) { TutOut("TipcSrvMainLoop failed: error <%s>.\n", TutErrStrGet()); } } /* This line should not be reached. */ return T_EXIT_FAILURE; } /* main */
This program retrieves both input and output information about the RTclients’ message traffic. The poll for traffic information is initiated by the call to TipcMonClientMsgTrafficPoll. Note that the argument to this function is unique_subject
. This argument is passed in as a command line argument and must be either:
In this program, the poll is sent to the specified RTclient or many RTclients at a regular interval, which is controlled by the call to TipcSrvMainLoop. The poll_interval
timeout causes TipcSrvMainLoop to read and process all incoming messages for that many seconds before giving up control.
The call to TipcMonClientMsgTrafficPoll results in one or a series (one for each RTclient polled) of MON_CLIENT_MSG_TRAFFIC_POLL_RESULT messages being returned to the program from RTserver. An RTclient message process callback, process_traffic_poll, is created to process messages of that type.
The callback function process_traffic_poll accesses the fields of the poll result message and prints the requested information. If no RTclient exists that matches the unique_subject
passed to TipcMonClientMsgTrafficPoll, no results are printed.
To compile, link, and run the polltraf
program, first you must either copy the program to your own directory or have write permission to the directory:
You are also going to run a program with some message traffic.
Copy the receive.c program from this directory
Note that this program is part of the ss_tutorial
project and subscribes to the lesson5
subject.
Compile and link the polltraf and receive programs
$ cc polltraf.c $ rtlink /exec=polltraf.exe polltraf.obj $ cc receive.c $ rtlink /exec=receive.exe receive.obj
To run the programs, start the receive
process in one terminal emulator window and then the polltraf
process in another terminal emulator window.
Start the receive program in the first window
Start the polltraf program in the second window
The name /...
indicates that all RTclients should be polled. Here is an example of the output displayed:
Polling RTclient </...> in project <ss_tutorial> every <10> seconds... Connecting to project <ss_tutorial> on <_node> RTserver. Using local protocol. Message from RTserver: Connection established. Start subscribing to subject </_grissom_1037>. ==> Polling RTclient </...> for message traffic info... Summary of message traffic for RTclient </_grissom_1028> Total messages received = 19 Total messages sent = 19 Total bytes received = 792 Total bytes sent = 792 ====================================================== Summary of message traffic for RTclient </_grissom_1037> Total messages received = 1 Total messages sent = 2 Total bytes received = 64 Total bytes sent = 64 ====================================================== ==> Polling RTclient </...> for message traffic info... Summary of message traffic for RTclient </_grissom_1028> Total messages received = 20 Total messages sent = 20 Total bytes received = 904 Total bytes sent = 904 ====================================================== Summary of message traffic for RTclient </_grissom_1037> Total messages received = 3 Total messages sent = 4 Total bytes received = 240 Total bytes sent = 240 ======================================================
Notice than when a poll takes place, two results are reported. One is for the receive program, the second is for the polltraf program. When /...
is used to specify all RTclients, polltraf even receives information about itself (which initiated the poll).
TIBCO SmartSockets™ User’s Guide Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |