Before you use RTserver and the RTclient C++ interfaces, it helps to have an understanding of the concepts involved. Figure 5 shows the RTserver and RTclient architecture.
This architecture is made up of these major concepts:
More detailed information can be found in the TIBCO SmartSockets User’s Guide.
The SmartSockets C++ class TipcSrv creates RTclient processes that connect to RTserver. TipcSrv is derived from the base class TipcConnClient.
Because most SmartSockets C API TipcConn* calls have a corresponding TipcSrv* equivalent that only operates on the connection to RTserver, many of the member functions in TipcConn are declared virtual, and the TipcSrv class reimplements them appropriately in its derived class. The C API TipcConn* functions that do not have TipcSrv* equivalents, such as TipcConnAccept(), do not appear in TipcConn, but rather appear in derived classes of TipcConn other than TipcSrv (such as TipcConnServer).
Because any given RTclient process is allowed to have, at most, one connection to RTserver at a time, the SmartSockets C++ class library does not allow you to construct an instance of a TipcSrv object. However, sometimes you may need to cause the C API’s TipcSrvCreate() to be called from C++ using some type of mechanism. Use the static member functions on the TipcSrv class, such as TipcSrv::InstanceCreate(), to obtain the TipcSrv functionality and optionally establish a connection to an RTserver process.
You can establish a full connection to RTserver in a single step or in two steps. This example illustrates connecting to RTserver in one step:
The next example illustrates connecting to RTserver in two steps.
TipcSrv& server = TipcSrv::Instance();
if (server.CreateCbLookup(create_cb, NULL) == NULL) {
server.CreateCbCreate(create_cb, NULL);
}
status = server.Create(T_IPC_SRV_CONN_FULL);
if (!status) {
// error
}
The advantage of calling TipcSrv::InstanceCreate() over the combination of TipcSrv::Instance() and TipcSrv::Create() is that TipcSrv::InstanceCreate() returns a handle to a TipcSrv object and creates a connection to RTserver in one step. The advantage of using the combination of TipcSrv::Instance() and TipcSrv::Create() is that TipcSrv::Instance() returns a reference to a TipcSrv object, which in turn is used to call TipcSrv member functions, such as TipcSrv::CreateCbCreate(), prior to connecting to RTserver with the TipcSrv::Create().
TIBCO SmartSockets™ cxxipc Class Library Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |