Important: The information in this document is obsolete and should not be used for new development.
OTSnd
Sends data to a remote peer using a connection-oriented, transactionless endpoint.C INTERFACE
OTResult OTSnd(EndpointRef ref, void* buf, size_t nbytes,C++ INTERFACE
OTResult TEndpoint::Snd(void* buf, size_t nbytes, OTFlags flags);PARAMETERS
ref- The endpoint reference of the endpoint sending data.
buf- A pointer to the data being sent.
nbytes- A 32-bit value specifying the number of bytes being sent.
flags- A 32-bit bitmapped value specifying whether the data to be sent is expedited (
T_EXPEDITED) and whether more data remains to be sent (T_MORE). To set both fields, use the bitwise OR operator.- function result
- A positive number indicating the actual number of bytes sent or a negative number indicating an error code. See Discussion.
DISCUSSION
You use theOTSndfunction to send data to a remote peer. Before you use this function, you must establish a connection with the peer.You specify the data to be sent by passing a pointer to the data (
buf) and by specifying the size of the data (nbytes). The maximum size of the data you can send is specified by thetsdufield of theTEndpointInfostructure for the endpoint or by theetsdufield for expedited data (T_EXPEDITEDflag set).Some protocols use expedited data for control or attention messages. To determine whether the endpoint supports this service, examine the
etsdufield of theTEndpointInfostructure. A positive integer for theetsdufield indicates the maximum size in bytes of expedited data that you can send. To send expedited data, you set theT_EXPEDITEDbit of theflagsparameter.If you want to break up the data into logical units, you can set the
T_MOREbit of theflagsparameter to indicate that you are using additional calls to theOTSndfunction to send more data that belongs to the same logical unit. To indicate that the last data unit is being sent, turn off theT_MOREflag. Only some endpoints support the preservation of logical units; you should check thetsdufield of theTEndpointInfostructure to find out if yours does.If the endpoint is in synchronous blocking mode, the
OTSndfunction returns after it actually sends the data. If flow-control restrictions prevent its sending the data, it retries the operation until it is able to send it.If the endpoint is in non-blocking or asynchronous mode, the
OTSndfunction returns with thekOTFlowErrresult if flow-control restrictions prevent the data from being sent. When the endpoint provider is able to send the data, it sendsaT_GODATAevent to let you know that it is possible to send data. You should wait for this event and then send the data again.If the endpoint is in non-blocking or asynchronous mode, it is also possible that only part of the data is actually accepted by the transport provider. In this case, the
OTSndfunction returns a value that is less than the value of thenbytesparameter. In this case, you should call the function again to send the remaining data.If an asynchronous event, such as a disconnect, occurs and interrupts the
OTSndfunction,OTSndreturns with thekOTLookErrresult.The following table shows how the endpoint's modes of operation affects the behavior of the
OTSndfunction.
Blocking Nonblocking Synchronous The function returns when the provider lifts flow-control restrictions. The function returns immediately. The kOTFlowErrresult is never returned.The kOTFlowErrresult might be returned.Asynchronous The function returns immediately. The function returns immediately. The kOTFlowErrresult might be returned.The kOTFlowErrresult might be returned.SPECIAL CONSIDERATIONS
TheXTI_SNDLOWAToption allows endpoints that support it to negotiate the minimum number of bytes that must have accumulated in the endpoint's internal send buffer before data is sent. See "Option Management".SEE ALSO
Table 4-4.