Important: The information in this document is obsolete and should not be used for new development.
OTRcv
Reads data sent using a connection-oriented transactionless endpoint.C INTERFACE
OTResult OTRcv(EndpointRef ref, void* buf, size_t nbytes, OTFlags* flags);C++ INTERFACE
OTResult TEndpoint::Rcv(void* buf, size_t nbytes, OTFlags* flags);PARAMETERS
ref- The endpoint reference of the endpoint receiving data.
buf- A pointer to a buffer where the incoming data is to be copied. You must allocate this buffer before you call the function.
nbytes- A 32-bit value specifying the size of the buffer in bytes.
flags- A 32-bit bitmapped value specifying, on return, whether the data being sent is expedited (
T_EXPEDITED) and whether more data remains to be received (T_MORE).- function result
- A positive integer specifying the number of bytes received or a negative integer specifying an error code. See Appendix B, and Discussion.
DISCUSSION
You call theOTRcvfunction to read data sent by the peer to which you are connected. If theOTRcvfunction succeeds, it returns a positive integer (OTResult) specifying the number of bytes received. The function places the data read into the buffer referenced by thebufparameter. If the function fails, it returns a negative integer corresponding to a result code that indicates the reason for the failure. You can call this function to receive either normal or expedited data. If the data is expedited, theT_EXPEDITEDflag is set in theflagsparameter.If the endpoint does not support the concept of a TSDU, the
T_MOREflag is not meaningful and should be ignored. To determine whether the endpoint supports TSDUs, examine thetsdufield of theTEndpointInfostructure. If the endpoint supports TSDUs and theT_MOREbit is set in theflagsparameter when the function returns, this means that the buffer you allocated is too small to contain the entire TSDU and that you must call theOTRcvfunction again. If you have read x bytes with the first call, the next call to theOTRcvfunction begins to read at the (x + 1) byte. Each call to this function that returns with theT_MOREflag set means that you must call the function again to get more of the TSDU. When you have read the entire TSDU, theOTRcvfunction returns with theT_MOREflag not set.If the
OTRcvfunction returns and theT_EXPEDITEDbit is set in theflagsparameter, this means that you have read expedited data. If the number of bytes in the ETSDU exceeds the number of bytes you specified in thereqCountparameter, both theT_EXPEDITEDand theT_MOREbits are set. You must call theOTRcvfunction until theT_MOREflag is not set to retrieve the rest of the ETSDU.If you are calling the
OTRcvfunction repeatedly to read normal data and a call to the function returnsT_EXPEDITEDin theflagsparameter, the next call to theOTRcvfunction that returns without theT_EXPEDITEDflag set returns normal data at the place it was interrupted. It is your responsibility to remember where that was and to continue processing normal data.If the endpoint is in synchronous blocking mode, the endpoint waits for data if none is currently available.If the endpoint is in asynchronous mode or is not blocking, the function returns with the
kOTNoDataErrresult if no data is available. For more information on notifier functions and event codes, seeMyNofierCallbackfunction and "Event Codes". If you have installed a notifier, the endpoint provider calls your notifier and passesT_DATAorT_EXDATAfor thecodeparameter when there is data available. If you have not installed a notifier, you may poll for these events using theOTLookfunction. Once you receive aT_DATAorT_EXDATAevent, you should continue in a loop, calling theOTRcvfunction until it returns with thekOTNoDataErrresult.SPECIAL CONSIDERATIONS
You should be prepared for aT_DATAevent and then akOTNoDataErrerror when you call theOTRcvfunction. This seems unusual, but it can occur if you were in the process of callingOTRcvin the foreground when aT_DATAevent comes in.Whenever the
OTRcvfunction returns akOTLookErrerror, it is very important that you call theOTLookfunction. If you are in a flow-control situation on the send side, and aT_GODATAorT_GOEXDATAevent occurs that you do not clear in your notifier (by callingOTLookor by actually sending some data), then you will hang waiting. Until theT_GODATAorT_GOEXDATAevents are cleared, Open Transport cannot send you anotherT_DATAevent (or any other event other than aT_DISCONNECTevent).The
XTI_RCVLOWAToption allows endpoints that support it to negotiate the minimum number of bytes that must have accumulated in the endpoint's internal receive buffer before the endpoint provider generates aT_DATAevent. See "Option Management" for information on setting this option.