Every TIBCO SmartSockets program has a non-interactive command interface available. In the RTclient environment, run-time commands can be executed in one of several ways:
By default, a RTclient understands commands such as setopt, quit, source, echo, and many others. Other commands, such as connect and subscribe, can be made available by calling TipcInitCommands. See the RTclient command language chapter in the TIBCO SmartSockets User’s Guide for more details on the available commands.
In the previous example, logging of messages was enabled by executing the setopt command directly in the program. Rather than hard-code commands to a TIBCO SmartSockets client directly in code, you can place the commands in a text file and source the file. For example, suppose you have created a text file, called receive3.cm
, containing these commands:
setopt log_in_data receive3.msg setopt log_in_internal receive3.msg setopt log_in_status receive3.msg setopt server_names workstation1, workstation2, workstation3 setopt server_start_timeout 10
To execute this command file, you can call the TIBCO SmartSockets utility function TutCommandParseFile, which executes all commands in the file. For example, if you wanted to allow a command-line argument containing the name of a command file to your receive3.c
program, this code can be added anywhere before the call to TipcSrvCreate:
if (argc == 2) {
if (!TutCommandParseFile(argv[1])) {
TutOut("Could not parse command file %s.\n", argv[1]);
TutExit(T_EXIT_FAILURE);
}
}
else {
/* Incorrect number of command line arguments */
TutOut("Usage: %s [ command_file_name ]\n", argv[0]);
TutExit(T_EXIT_FAILURE);
}
Start the receiving program
To run the receiving example and execute the receive3.cm
file, enter this command at the operating system prompt:
TIBCO SmartSockets™ Tutorial Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |