A TIBCO SmartSockets project is a group of RTclients working together with one or more RTservers to perform the goal of a specific system. Within a project, processes can communicate with other processes on the same machine or over the network. RTclients in different projects cannot send messages to each other.
An RTclient belongs to only one project. An RTserver does not belong to projects, but can provide message routing services for one or more projects. A project can be thought of as a firewall that prevents messages from being dispatched outside the specified process group.
A project is designated by a name, which must be an identifier (often the name of the application). The option Project is used to specify the project to which an RTclient belongs. The default value for Project is rtworks
. Always set this option to prevent becoming part of the default rtworks
project, which might cause unwanted messages to be received.
In the sending and receiving programs you wrote in Lesson 1, the Project option was not explicitly set. This resulted in these programs being part of the default project, rtworks
. You should set this option to build a firewall between your project and others that may be using TIBCO SmartSockets. Now you are going to set the Project option explicitly in your send
program.
Modify the sending program from Lesson 1
In your favorite text editor, modify the sending program from the previous lesson to look as shown in the next example. Or, you can copy the program from the file /tutorial/lesson2/send.c
into your working directory. Under Windows you also need the makefile sendw32m.mak
in your working directory. Use the command chmod 777 *
to allow write access to the sample programs you copy.
/* send.c - send INFO message to /tutorial/lesson2 subject */
/* $RTHOME/examples/smrtsock/tutorial/lesson2/send.c */
1 #include <rtworks/ipc.h> 2 int main(int argc, char **argv) { 3 T_OPTION option; 4 option = TutOptionLookup("project"); 5 TutOptionSetEnum(option, "smartsockets"); 6 TipcSrvCreate(T_IPC_SRV_CONN_FULL); 7 TipcSrvMsgWrite("/tutorial/lesson2", TipcMtLookupByNum(T_MT_INFO), TRUE, T_IPC_FT_STR, "Hello World!", NULL); 8 TipcSrvFlush(); 9 TipcSrvDestroy(T_IPC_SRV_CONN_NONE); }/* main */
Let’s examine some of the key lines about your new sending program:
Compile and link the sending program
Now compile and link your sending program as before.
Start the RTserver
If it isn’t already running, start RTserver:
![]() |
On platforms that support both 32- and 64-bit, use the rtserver64 command to run the 64-bit RTserver.
|
Start the receiving program
Then start the receiving program:
Start the sending program
After a few moments, start the sending program:
You should notice that the receiving program never read or printed out the message from the sending program. This is because you set the Project option in the sending program to smartsockets
and you have not yet set the Project option in the receiving program (thus, the Project defaulted to rtworks
for the receiving program). Therefore, RTserver prevents the message from the sending program being delivered to the receiving program because it is in a separate project from the sending program. To fix this problem, you need to modify receive.c
to belong to the same project as send.c
and to receive the /tutorial/lesson2
subject.
Edit or copy this receive.c program
Edit the following program using your favorite text editor or copy it from /tutorial/lesson2/receive.c
into your working directory. Under Windows you also need the makefile recvw32m.mak
in your working directory. The project must be set before connecting to RTserver with TipcSrvCreate.
/* receive.c - read an INFO message and print out its contents */
/* $RTHOME/examples/smrtsock/tutorial/lesson2/receive.c */
1 #include <rtworks/ipc.h> 2 int main(int argc, char **argv) { 3 T_OPTION option; 4 T_IPC_MSG msg; 5 T_STR msg_text; 6 option = TutOptionLookup("project"); 7 TutOptionSetEnum(option, "smartsockets"); 8 TipcSrvCreate(T_IPC_SRV_CONN_FULL); 9 TipcSrvSubjectSetSubscribe("/tutorial/lesson2", TRUE); 10 msg = TipcSrvMsgNext(T_TIMEOUT_FOREVER); 11 TipcMsgSetCurrent(msg, 0); 12 TipcMsgNextStr(msg, &msg_text); 13 TutOut("Text from INFO message = %s\n", msg_text); 14 TipcSrvDestroy(T_IPC_SRV_CONN_NONE); }/* main */
Compile and link the receiving program
Now compile and link the receiving program as before.
Start the receiving program
Start the receiving and sending programs in separate windows as you did earlier in this lesson. First start the receiving program:
Start the sending program
Then, after a few moments, start the sending program:
This output is displayed by the receiving program:
TIBCO SmartSockets™ Tutorial Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |