t_bind() — Bind an address to a transport endpoint

Standards

Standards / Extensions C or C++ Dependencies
XPG4.2 both  

Format

#define _XOPEN_SOURCE_EXTENDED 1
#include <xti.h>

int t_bind(int fd, struct t_bind *req, struct t_bind *ret);

General description

Associates a protocol address with the transport endpoint specified by fd and activates that transport endpoint. In connection mode, the transport provider may begin enqueuing incoming connect indications, or servicing a connection request on the transport endpoint. In connectionless mode, the transport user may send or receive data units through the transport endpoint.

The req and ret arguments point to a t_bind structure containing the following members:
        struct netbuf   addr;
        unsigned        qlen;
The addr field of the t_bind structure specifies a protocol address, and the qlen field is used to indicate the maximum number of outstanding connect indications.

The parameter req is used to request that an address, represented by the netbuf structure, be bound to the given transport endpoint. The parameter len specifies the number of bytes in the address, and buf points to the address buffer. The parameter maxlen has no meaning for the req argument. On return, ret contains the address that the transport provider actually bound to the transport endpoint. This is the same as the address specified by the user in req. In ret, the user specifies maxlen, which is the maximum size of the address buffer, and buf which points to the buffer where the address is to be placed. On return, len specifies the number of bytes in the bound address, and buf points to the bound address. If maxlen is not large enough to hold the returned address, an error results.

If the requested address is not available, t_bind() returns -1 with t_errno set as appropriate. If no address is specified in req (the len field of addr in req is zero or req is NULL), the transport provider will assign an appropriate address to be bound, and will return that address in the addr field of ret. If the transport provider could not allocate an address, t_bind() fails with t_errno set to TNOADDR.

The parameter req may be a NULL pointer if the user does not wish to specify an address to be bound. Here, the value of qlen is assumed to be zero, and the transport provider assigns an address to the transport endpoint. Similarly, ret may be a NULL pointer if the user does not care what address was bound by the provider and is not interested in the negotiated value of qlen. It is valid to set req and ret to the NULL pointer for the same call, in which case the provider chooses the address to bind to the transport endpoint and does not return that information to the user.

The qlen field specifies the number of outstanding connect indications that the transport provider should support for the given transport endpoint. An outstanding connect indication is one that has been passed to the transport user by the transport provider, but which has not been accepted or rejected. A value of qlen greater than 0 is only meaningful when issued by a passive transport user that expects other users to call it. The value of qlen will be negotiated by the transport provider and will always be negotiated to 1 (one) from any nonzero value. On return, the qlen field in ret will contain the negotiated value.

If fd refers to a connection-oriented service, then multiple endpoints my be bound to the same protocol address by way of connections accepted on an endpoint using t_accept. The TCP transport provider will not permit the user to explicitly bind multiple endpoints to the same address. It is also not possible to bind an endpoint to more than one protocol address. If a user attempts to explicitly bind multiple endpoints to a protocol address, the second and subsequent binds will fail with t_errno set to TADDRBUSY. When a user accepts a connection on the transport endpoint that is being used as the listening endpoint, the bound protocol address will be found to be busy for the duration of the connection, until a t_unbind() or t_close() call has been issued. No other transport endpoints may be bound for listening on that same protocol address while that initial listening endpoint is active (in the data transfer phase or in the T_IDLE state). This prevents more than one transport endpoint bound to the same protocol address from accepting connect indications.

Valid states: T_UNBND

Returned value

If successful, t_bind() returns 0.

If unsuccessful, t_bind() returns -1 and sets errno to one of the following values:
Error Code
Description
TACCES
The user does not have permission to use the specified address.
TADDRBUSY
The requested address is in use.
TBADADDR
The specified protocol address was in an incorrect format or contained illegal information.
TBADF
The specified file descriptor does not refer to a transport endpoint.
TBUFOVFLW
The number of bytes allowed for an incoming argument (maxlen) is greater than 0 but not sufficient to store the value of that argument. The provider's state will change to T_IDLE and the information to be returned in ret will be discarded.
TNOADDR
The transport provider could not allocate an address.
TOUTSTATE
The function was issued in the wrong sequence.
TPROTO
This error indicates that a communication problem has been detected between XTI and the transport provider for which there is no other suitable XTI (t_errno).
TSYSERR
A system error has occurred during execution of this function.

Related information