Important: The information in this document is obsolete and should not be used for new development.
OTRcvReply
Reads a transaction reply sent by a connection-oriented responder.C INTERFACE
OSStatus OTRcvReply(EndpointRef ref, TReply* reply, OTFlags* replyFlags);C++ INTERFACE
OSStatus TEndpoint::RcvReply(TReply* reply, OTFlags* replyFlags);PARAMETERS
ref- The endpoint reference of the endpoint reading the reply.
reply- A pointer to a
TReplystructure that specifies where to store the reply information. You must allocate buffers to contain the reply data, option values, and the transaction ID of the request to which the reply is being sent, and you must specify the maximum size of this data.
- The
reply->data.buffield points to a buffer in which the reply data is to be stored. Set thereply->data.maxlenfield to the maximum size of the reply data.
- The
reply->opt.buffield points to a buffer in which option values are stored. Set thereply->opt.maxlenfield to the maximum size of this data.
- The
reply->sequencefield specifies the transaction ID of the transaction to which the reply is sent. If you have sent out multiple requests, you can examine this field to match replies to requests.
replyFlags- A bitmapped 32-bit value specifying
T_MOREorT_PARTIALDATA. A value ofT_MOREindicates that the buffer pointed to byreply->data.bufis too small to contain the reply. A value ofT_PARTIALDATAindicates that the data unit being read does not contain the complete reply and that the next data unit might belong to a different transaction.
- function result
- An error code. See Appendix B, and Discussion.
DISCUSSION
You use theOTRcvReplyfunction to read the reply to a request that you sent using theOTSndRequestfunction.If the endpoint is in asynchronous mode, the endpoint provider issues the
T_REPLYevent to let you know that incoming reply data is available. After you retrieve this event, using theOTLookfunction or your notifier function, you must call theOTRcvReplyfunction repeatedly to read the reply data until it returnskOTNoDataErr. The endpoint provider does not generate additionalT_REPLYevents until you have read the complete reply.If a transaction has timed out awaiting reply data, the
OTRcvReplyfunction returns akETIMEDOUTErrresult; thesequencefield of thereplyparameter specifies which request has timed out.If you have issued multiple requests, it is not possible to know ahead of time how incoming replies match your requests. You must be prepared to receive a reply to any outstanding request. One way to manage this situation is to call the
OTRcvReplyfunction with thereply->udata.maxlenfield set to 0. The rest of the information returned by the function on this first call lets you know the sequence number of the reply as well as thereplyFlagssetting. Once you determine the matching request and the appropriate reply buffer, you can call theOTRcvReplyfunction a second time to read the actual reply data. On the second and subsequent reads, Open Transport sets thereply->opt.lenfield to 0. It is guaranteed that once a reply has been partially read, subsequent calls toOTRcvReplyread from that same reply until all the available data has been read. TheT_PARTIALDATAevent might be returned if the entire reply is not available.If the
T_MOREbit is set in thereplyFlagsparameter, this means your buffer is not large enough to hold the entire reply. You must call theOTRcvRequestfunction again to retrieve more request data. Open Transport ignores theaddrandoptfields of thereplyparameter for subsequent calls to the function. TheT_MOREflag is not set for the last reply packet to let you know that this is the last packet.If the
T_PARTIALDATAbit is set in thereplyFlagsparameter, this means that the data you are about to read with theOTRcvReplyfunction does not constitute the entire reply and that more data is coming, but it has not yet arrived. You must call the function again to read more, or the rest, of the reply.If the
T_MOREand theT_PARTIALDATAbits are both set, this means that the data you are about to read constitutes only part of the reply and that your buffer is too small to contain even this chunk. In this case, you must call the function again until theT_MOREflag is clear. TheT_PARTIALDATAbit is set only on the first call to the function.If you are communicating with multiple responders and if the
OTRcvUReplyfunction returns with theT_PARTIALDATAflag set, it is possible that your next call to the function might not read the rest of the reply because the next data unit coming in belongs to a different reply. One way to handle this situation is to use the next call to theOTRcvReplyfunction to determine the sequence number of the incoming reply (by settingreq->udata.maxlento 0) and then, having determined which reply data is coming in, read the data into the appropriate buffer.SEE ALSO
TheOTSndRequestfunction.