OTRcvUReply
Reads a reply to a request sent by a client using a connectionless transaction-
based protocol.C INTERFACE
OSStatus OTRcvUReply (EndpointRef ref, TUnitReply* reply, OTFlags* flagPtr);C++ INTERFACE
OSStatus TEndpoint::RcvUReply(TUnitReply* reply, OTFlags* flags);PARAMETERS
ref- The endpoint reference of the endpoint accepting the reply.
reply- A pointer to a
TUnitReplystructure (page 3-60) that contains information about the reply data and the ID of the transaction. See the description of theTUnitReplystructure for how to set this parameter when doing a no-copy receive.flagPtr- A pointer to a bitmapped long that is filled in by the endpoint provider to indicate whether there is more reply data to be
read, in which case you must call theOTRcvUReplyfunction again. A value ofT_MOREindicates that the buffer pointed to
byudata.bufis too small to contain the reply. A value ofT_PARTIALDATAindicates that the data unit being read does not contain the complete reply. It is possible that both flags are set.DESCRIPTION
You use theOTRcvUReplyfunction to read the reply to a request that you have issued using theOTSndURequestfunction. Thereplyparameter points to buffers in which the function stores the reply, the address of the responder, any options connected with this transaction, and the transaction ID for this transaction.If the endpoint is in asynchronous mode, the provider generates a
T_REPLYevent to let you know that reply data has arrived. If it should happen that the reply data is sent using multiple calls to the sending function, Open Transport does not generate additionalT_REPLYevents. To guard against this possibility, your notifier function should call theOTRcvUReplyfunction until it returns thekOTNoDataErrresult.If a transaction has timed out awaiting reply data, the
OTRcvUReplyfunction 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
OTRcvUReplyfunction 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 theflagPtrsetting. Once you determine the matching request and the appropriate reply buffer, you can call theOTRcvUReplyfunction 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 toOTRcvUReplyread from that same reply until all the data has been read.If the
T_MOREbit is set in theflagsparameter, this means your buffer is not large enough to hold the entire reply. You must call theOTRcvURequestfunction 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 theflagsparameter, this means that the data you are about to read with theOTRcvUReplyfunction does not constitute the entire reply and that you must call the function again to read more of 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.VALID STATES
T_IDLESEE ALSO
You use theOTSndURequestfunction (page 3-107) to send a request.For information on how to use this function with the AppleTalk ATP protocol, see page 14-10 in the ATP chapter.
You use the
TUnitReplystructure (page 3-60) to store information about the reply data and the ID of the transaction.