TipcMsgSetNumFields set the number of fields in a message
msg
message to set number of fields for
num_fields
number of fields
TRUE
if the number of fields was successfully set for the message, FALSE
otherwise.
If TipcMsgSetNumFields fails, it returns FALSE
and sets the global SmartSockets error number to one of:
msg
was nullmsg
was not a valid messagenum_fields
was less than 0num_fields
was greater than the number of fields in the message
TipcMsgSetNumFields sets the number of fields in a message by truncating the message to the desired number of fields. If num_fields
is 0, the message is completely emptied (the message data buffer is not changed, but any fields in the data buffer are lost). TipcMsgSetNumFields is useful for reusing messages, rather than continually destroying and creating messages.
There is no way to recover the old fields in a message after calling TipcMsgSetNumFields.
TipcMsgSetCurrent, TipcMsgTraverse
This example creates a message, appends fields, empties the message, and appends different fields:
T_IPC_MT mt; T_IPC_MSG msg; mt = TipcMtLookupByNum(T_MT_NUMERIC_DATA); if (mt == NULL) {return
; /* error */
} msg = TipcMsgCreate(mt); if (msg == NULL) {return
; /* error */
} if (!TipcMsgAppendStrReal8(msg, "speed_limit", 65.0)) {return
; /* error */
} if (!TipcMsgSetNumFields(msg, 0)) {return
; /* error */
} if (!TipcMsgAppendStrReal8(msg, "speed_limit", 35.0)) {return
; /* error */
}
TIBCO SmartSockets™ Application Programming Interface Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |