[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Communications Technical Reference, Volume 2

t_snd Subroutine for Transport Layer Interface

Purpose

Sends data or expedited data over a connection.

Library

Transport Layer Interface Library (libtli.a)

Syntax

#include <tiuser.h>
int t_snd(fd, buf, nbytes, flags)
int fd;
char *buf;
unsigned nbytes;
int flags;

Description

The t_snd subroutine is used to send either normal or expedited data.

By default, the t_snd subroutine operates in synchronous mode and may wait if flow-control restrictions prevent the data from being accepted by the local transport provider at the time the call is made. However, if the O_NDELAY or O_NONBLOCK flag is set (using the t_open subroutine or the fcntl command), the t_snd subroutine runs in asynchronous mode and stops immediately if there are flow-control restrictions.

Even when there are no flow-control restrictions, the t_snd subroutine will wait if STREAMS internal resources are not available, regardless of the state of the O_NDELAY or O_NONBLOCK flag.

On successful completion, the t_snd subroutine returns the number of bytes accepted by the transport provider. Normally this equals the number of bytes specified in the nbytes parameter. However, if the O_NDELAY or O_NONBLOCK flag is set, it is possible that only part of the data will be accepted by the transport provider. In this case, the t_snd subroutine sets the T_MORE flag for the data that was sent and returns a value less than the value of the nbytes parameter. If the value of the nbytes parameter is 0, no data is passed to the provider and the t_snd subroutine returns a value of 0.

Parameters

fd Identifies the local transport end point through which data is sent.
buf Points to the user data.
nbytes Specifies the number of bytes of user data to be sent.
flags Specifies any optional flags.

If the T_EXPEDITED flag is set in the flags parameter, the data is sent as expedited data and is subject to the interpretations of the transport provider.

If the T_MORE flag is set in the flags parameter, or as described above, an indication is sent to the transport provider that the transport service data unit (TSDU) or expedited transport service data unit (ETSDU) is being sent through multiple t_snd subroutine calls. Each t_snd subroutine with the T_MORE flag set indicates that another t_snd subroutine will follow with more data for the current TSDU. The end of the TSDU or ETSDU is identified by a t_snd subroutine call with the T_MORE flag not set. Use of the T_MORE flag enables a user to break up large logical data units without losing the boundaries of those units at the other end of the connection. The flag implies nothing about how the data is packaged for transfer below the transport interface. If the transport provider does not support the concept of a TSDU as indicated in the info parameter on return from the t_open or t_getinfo subroutine, the T_MORE flag is not meaningful and should be ignored.

The size of each TSDU or ETSDU must not exceed the limits of the transport provider as returned by the t_open or t_getinfo subroutine. If the size is exceeded, a TSYSERR error with system error EPROTO occurs. However, the t_snd subroutine may not fail because EPROTO errors may not be reported immediately. In this case, a subsequent call that accesses the transport endpoint fails with the associated TSYSERR error.

If the call to the t_snd subroutine is issued from the T_IDLE state, the provider may silently discard the data. If the call to the t_snd subroutine is issued from any state other than T_DATAXFER, T_INREL, or T_IDLE, the provider generates a TSYSERR error with system error EPROTO (which can be reported in the manner described above).

Return Values

On successful completion, the t_snd subroutine returns the number of bytes accepted by the transport provider. Otherwise, it returns a value of -1 and sets the t_errno variable to indicate the error.

Error Codes

If unsuccessful, the t_errno variable is set to one of the following:

TBADDATA The amount of user data specified was not within the bounds allowed by the transport provider.
TBADF The specified file descriptor does not refer to a transport end point.
TBADFLAG The value specified in the flags parameter is invalid.
TFLOW The O_NDELAY or O_NONBLOCK flag was set, but the flow-control mechanism prevented the transport provider from accepting data at this time.
TLOOK An asynchronous event has occurred on the transport end point reference by the fd parameter and requires immediate attention.
TNOTSUPPORT This subroutine is not supported by the underlying transport provider.
TOUTSTATE The subroutine was issued in the wrong sequence.
TSYSERR A system error has been detected during execution of this subroutine.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The t_getinfo subroutine, t_getstate subroutine, t_open subroutine, t_rcv subroutine.

List of Streams Programming References and STREAMS Overview in AIX Version 4.3 Communications Programming Concepts.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]