Message Files


A message file is a representation of one or more messages. The content of the file is text or binary. It provides a means to represent messages in a file. See the TIBCO SmartSockets User’s Guide for more information on the features of message files.

Using Message Files

In the SmartSockets C++ class library, message files are managed by the TipcMsgFile class. There are two constructors from the TipcMsgFile class. The first constructor can be used to open an existing file for reading, to open an existing file for appending, or to create a new file for writing. For example:

TipcMsgFile msg_file("output.msg", T_IPC_MSG_FILE_CREATE_WRITE); 
if (!msg_file) { 
    // error 
} 

Messages are written to the file using the insertion operator (operator<<). For example:

TipcMsg msg(T_MT_NUMERIC_DATA); 
msg << "Temperature" << (T_REAL8)98.6 << Check; 
if (!msg) { 
    // error 
} 
 
msg_file << msg; 
if (!msg_file) { 
    // error 
} 

The second constructor creates a TipcMsgFile object from an existing C FILE pointer.

The Check manipulator cannot be used with TipcMsgFile objects. In fact, the compiler generates an error if it is attempted. The Check manipulator can only be used in TipcMsg function chains.

Messages are read from a message file using the extraction operator (operator>>()). For example:

TipcMsgFile msg_file("input.msg", T_IPC_MSG_FILE_CREATE_READ); 
if (!msg_file) { 
    // error 
} 
 
TipcMsg msg; 
msg_file >> msg; 
if (!msg_file) { 
    // error 
} 

TIBCO SmartSockets™ cxxipc Class Library
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com