Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

t_bind() - assign a transport endpoint an address

&pagelevel(4)&pagelevel

#include <xti.h>

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

Description

The user calls the t_bind() function to assign the transport endpoint specified by the fd parameter a protocol address and activates the transport endpoint.

After successful execution of t_bind(), the user has the following options:

  • The user can call t_listen() in connection-oriented mode to check the transport endpoint specified by fd for pending connection requests and then, if necessary, use t_accept() to accept connections on fd. The user can also send connection requests to other transport endpoints over transport endpoint fd with t_connect().

  • In connectionless mode, the user can send or receive datagrams over the transport endpoint specified by fd.

The req and ret parameters each point to an object of type struct t_bind.

The t_bind structure is declared in <xti.h> as follows:

struct t_bind {
   struct netbuf addr;
   unsigned qlen;
};

The user specifies the protocol address to be assigned to the transport endpoint in req->addr. The user specifies the length of this address in bytes in req->addr.len.

req->addr.buf points to the address buffer. req->addr.maxlen is meaningless. The transport user passes a pointer to a buffer in ret->addr.buf and specifies the maximum length of this buffer in ret->addr.maxlen. After successful execution, t_bind() returns the address assigned to transport endpoint fd in ret-> addr.buf. t_bind() returns the actual length of this address in ret->addr.len.

t_bind() returns the TBUFOVFLW error code if the length specified in ret->addr.maxlen is too small for storing the address returned by t_bind(). However, the state of the transport endpoint changes to T_IDLE.

req->qlen and ret->qlen are only significant if fd is run in connection-oriented mode, in which case they define the maximum number of pending connection requests that the transport provider supports for transport endpoint fd. A pending connection request is a connection request which was passed to the endpoint of the user by the transport system and has to date neither been accepted (t_accept()) nor refused (t_snddis()) by this user.
The number of connection requests for transport endpoint fd supported by the transport provider is calculated as follows:

  • Before calling t_bind(), the user specifies in req->qlen the number of pending connection requests that the transport provider is to support on transport endpoint fd. req->qlen > 0 is only meaningful with a transport endpoint that the user later monitors passively for pending connection requests with t_listen().

  • req->qlen is evaluated by the transport provider. If the transport provider cannot support the number of pending connection requests specified in req->qlen, he reduces the value passed in req->qlen appropriately. However, the transport provider never reduces a req->qlen value that is > 0 to 0. The transport provider can currently support a maximum of 8 pending connection requests.

  • t_bind() returns the number of pending connection requests that the transport provider actually supports for transport endpoint fd in ret->qlen.

If the user does not want to specify the address to be bound (assigned) to transport endpoint fd, he passes the null pointer as the current parameter for req. In this case, the transport provider selects the address to be bound, whereby he implicitly assumes a value of 0 for req->qlen.

The user can also pass the null pointer as the current parameter for ret, if he is indifferent to the value of qlen and the address bound to fd with t_bind() by the transport provider.

It is permissible to pass the null pointer for both req and ret in the same t_bind() call. The transport provider then selects the address which is bound to fd. However, t_bind() does not return this information to the user.

Return value

0:

If successful.

-1:

If an error occurs. t_ errno is set to indicate the error.

Errors

TACCES

The user has no allowance to use the specified address.

TADDRBUSY

The specified protocol address is already in use.

TBADADDR

The specified protocol address has the wrong format or contains invalid information.

TBADF

The specified file descriptor does not reference a transport endpoint.

TBUFOVFLW

The allowed number of bytes for a result parameter is too small to store the value of the parameter. The state of the transport provider is changed to T_IDLE and the information to be returned in *ret is deleted.

TNOADDR

The transport provider could not reserve an address (see also "Dependencies on the BS2000 transport system BCAM").

TOUTSTATE

The function was called in the wrong position within a sequence of XTI function calls for transport endpoint fd.

TSYSERR

A system error occurred during execution of this function.

See also

t_open(), t_optmgmt(), t_unbind()