TipcMsgAppendReal4ArrayPtr


Name

TipcMsgAppendReal4ArrayPtr — use a pointer to append a field containing an array of REAL4 fields to a message

Synopsis

T_BOOL TipcMsgAppendReal4ArrayPtr(msg, real4_array_data, array_size, 
                                  field_return) 
T_IPC_MSG msg; 
T_REAL4 *real4_array_data; 
T_INT4 array_size; 
T_IPC_MSG_FIELD *field_return; 

Arguments

msg — message to append field to

real4_array_data — data for new message field

array_size — number of elements in real4_array_data

field_return — optional location to return field (use NULL if not needed)

Return Values

TRUE if the field was successfully appended to the message, FALSE otherwise.

Diagnostics

If TipcMsgAppendReal4ArrayPtr fails, it returns FALSE and sets the global SmartSockets error number to one of:

Description

TipcMsgAppendReal4ArrayPtr appends a four-byte real array (REAL4_ARRAY) field containing real4_array_data to the end of a message’s data. This function does not make a copy of the array. Instead, the supplied pointer to the array is entered directly into the new message field’s internal data structure. The caller is responsible for making sure that the pointer remains valid for the lifetime of the message field, and for freeing it, if necessary, when the message field has been destroyed.

One advantage of TipcMsgAppendReal4ArrayPtr over TipcMsgAppendReal4Array is that the array data can be modified after the field is appended, but before the message is sent. Also, the overhead of one copy operation is avoided, because the data is still copied into the connection write buffer when the message is sent.

To update the pointer to point to a new memory location, use the TipcMsgFieldUpdateReal4ArrayPtr function.

See Also

TipcMsgAppendReal4Array, TipcMsgNextReal4Array, TipcMsgFieldSetSize, TipcMsgFieldUpdateReal4ArrayPtr

Examples

This example creates a message and appends a REAL4_ARRAY field:

T_IPC_MT mt; 
T_IPC_MSG msg; 
T_REAL4 data[10]; 
T_IPC_MSG_FIELD field; 
 
#define USER_MT_REAL4_ARRAY_TEST 100 
mt = TipcMtCreate("real4_array_test", USER_MT_REAL4_ARRAY_TEST, 
                  "real4_array"); 
if (mt == NULL) { 
  return;  /* error */ 
} 
 
msg = TipcMsgCreate(mt) 
if (msg == NULL) { 
  return;  /* error */ 
} 
 
/* An RTclient would typically set the destination of */ 
/* a message at this point by calling TipcMsgSetDest. */ 
 
if (!TipcMsgAppendReal4ArrayPtr(msg, data, 0, &field)) { 
  return;  /* error */ 
} 
 
data[0] = 56.1; 
data[1] = 57.2; 
if (!TipcMsgFieldSetSize(field, 2)) { 
  return;  /* error */ 
} 
 
/* A process would typically send a message at this point by */ 
/* calling TipcConnMsgSend or TipcSrvMsgSend. */ 
 
/* A process would typically destroy a message at this point by */ 
/* calling TipcMsgDestroy. */ 

TIBCO SmartSockets™ Application Programming Interface
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com