Prosody data communications: API: smdc_tx_data

Prototype Definition

int smdc_tx_data(struct smdc_data_parms *datap)

Parameters

*datap
a structure of the following type:
typedef struct smdc_data_parms {
	tSMChannelId channel;					/* in */
	char *data;						/* in */
	tSM_INT max_length;					/* in */
	tSM_INT done_length;					/* out */
} SMDC_DATA_PARMS;

Description

Attempt to write data to a channel whose output half has been configured for a data commuications protocol. Less than the maximum will be written when either:

To permit maximum system throughput, this function refuses to write to a channel whose status has changed since it was last checked. This allows an application to avoid checking the status during bulk data transfer. The application only needs to check the status (using smdc_tx_status()) when a call to smdc_tx_data() returns with done_length equal to zero. If a status change occurs while writing data, done_length may indicate that some, but not all, of the data was written. In this case, the most convenient way for an application to react is often to note how much data has been sent, and to try to send more. Since the new attempt will indicate that no data was written, it means that the application does not need to have different cases to handle a status change at the beginning of the data buffer and a status change after a partial write.

See also the document Prosody Data Communcations Protocols and Encodings for details of behaviour specific to individual protocols and encodings.

Fields

channel
The data communication channel.
data
A pointer to the data to be written.
max_length
The amount of data in the buffer.
done_length
The amount of data actually written.

Returns

0 if call completed successfully, otherwise a standard error such as:


This function is part of the Prosody data communications API.