Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
7.  Programming With XTI and TLI State Transitions State Tables  Previous   Contents   Next 
   
 

The following table shows connection establishment/connection release/data transfer in connection mode.

Table 7-6 Connection Mode State--Part 2

Event/State

T_OUTREL

T_INREL

T_UNBND

connect1

 

 

 

connect2

 

 

 

rcvconnect

 

 

 

listen

 

 

 

accept1

 

 

 

accept2

 

 

 

accept3

 

 

 

snd

 

T_INREL

 

rcv

T_OUTREL

 

 

snddis1

T_IDLE

T_IDLE

 

snddis2

 

 

 

rcvdis1

T_IDLE

T_IDLE

 

rcvdis2

 

 

 

rcvdis3

 

 

 

sndrel

 

T_IDLE

 

rcvrel

T_IDLE

 

 

pass_conn

 

 

T_DATAXFER

optmgmt

T_OUTREL

T_INREL

T_UNBND

closed

T_UNINIT

T_UNINIT

 

The following table shows

Table 7-7 Connectionless Mode State

Event/State

T_IDLE

snudata

T_IDLE

rcvdata

T_IDLE

rcvuderr

T_IDLE

Guidelines to Protocol Independence

The set of XTI/TLI services, common to many transport protocols, offers protocol independence to applications. Not all transport protocols support all XTI/TLI services. If software must run in a variety of protocol environments, use only the common services.

The following is a list of services that might not be common to all transport protocols.

  • In connection mode service, a transport service data unit (TSDU) might not be supported by all transport providers. Make no assumptions about preserving logical data boundaries across a connection.

  • Protocol and implementation-specific service limits are returned by the t_open(3NSL) and t_getinfo(3NSL) routines. Use these limits to allocate buffers to store protocol-specific transport addresses and options.

  • Do not send user data with connect requests or disconnect requests, such as t_connect(3NSL) and t_snddis(3NSL). Not all transport protocols can use this method.

  • The buffers in the t_call structure used for t_listen(3NSL) must be large enough to hold any data sent by the client during connection establishment. Use the T_ALL argument to t_alloc(3NSL) to set maximum buffer sizes to store the address, options, and user data for the current transport provider.

  • Do not specify a protocol address on t_bind(3NSL) on a client-side endpoint. The transport provider should assign an appropriate address to the transport endpoint. A server should retrieve its address for t_bind(3NSL) in a way that does not require knowledge of the transport provider's name space.

  • Do not make assumptions about formats of transport addresses. Transport addresses should not be constants in a program. Chapter 8, Transport Selection and Name-to-Address Mapping contains detailed information about transport selection.

  • The reason codes associated with t_rcvdis(3NSL) are protocol-dependent. Do not interpret these reason codes if protocol independence is important.

  • The t_rcvuderr(3NSL) error codes are protocol dependent. Do not interpret these error codes if protocol independence is a concern.

  • Do not code the names of devices into programs. The device node identifies a particular transport provider and is not protocol independent. See Chapter 8, Transport Selection and Name-to-Address Mapping for details regarding transport selection.

  • Do not use the optional orderly release facility of the connection mode service, provided by t_sndrel(3NSL) and t_rcvrel(3NSL), in programs targeted for multiple protocol environments. This facility is not supported by all connection-based transport protocols. Using the facility can prevent programs from successfully communicating with open systems.

XTI/TLI Versus Socket Interfaces

XTI/TLI and sockets are different methods of handling the same tasks. Although they provide mechanisms and services that are functionally similar, they do not provide one-to-one compatibility of routines or low-level services. Observe the similarities and differences between the XTI/TLI and socket-based interfaces before you decide to port an application.

The following issues are related to transport independence, and can have some bearing on RPC applications:

  • Privileged ports - Privileged ports are an artifact of the Berkeley Software Distribution (BSD) implementation of the TCP/IP Internet Protocols. These ports are not portable. The notion of privileged ports is not supported in the transport-independent environment.

  • Opaque addresses - Separating the portion of an address that names a host from the portion of an address that names the service at that host cannot be done in a transport-independent fashion. Be sure to change any code that assumes it can discern the host address of a network service.

  • Broadcast - No transport-independent form of broadcast address exists.

Socket-to-XTI/TLI Equivalents

The following table shows approximate equivalents between XTI/TLI interfaces and socket interfaces. The comment field describes the differences. If the comment column is blank, either the interfaces are similar or no equivalent interface exists in either interface.

Table 7-8 TLI and Socket Equivalent Functions

TLI interface

Socket interface

Comments

t_open(3NSL)

socket(3SOCKET)

-

socketpair(3SOCKET)

t_bind(3NSL)

bind(3SOCKET)

t_bind(3NSL) sets the queue depth for passive sockets, but bind(3SOCKET) does not. For sockets, the queue length is specified in the call to listen(3SOCKET).

t_optmgmt(3NSL)

getsockopt(3SOCKET)

setsockopt(3SOCKET)

t_optmgmt(3NSL) manages only transport options. getsockopt(3SOCKET) and setsockopt(3SOCKET) can manage options at the transport layer, but also at the socket layer and at the arbitrary protocol layer.

t_unbind(3NSL)

-

 

t_close(3NSL)

close(2)

t_getinfo(3NSL)

getsockopt(3SOCKET)

t_getinfo(3NSL) returns information about the transport. getsockopt(3SOCKET) can return information about the transport and the socket.

t_getstate(3NSL)

-

t_sync(3NSL)

-

t_alloc(3NSL)

-

t_free(3NSL)

-

t_look(3NSL)

-

getsockopt(3SOCKET) with the SO_ERROR option returns the same kind of error information as t_look(3NSL)t_look().

t_error(3NSL)

perror(3C)

t_connect(3NSL)

connect(3SOCKET)

You do not need to bind the local endpoint before invoking connect(3SOCKET). Bind the endpoint before calling t_connect(3NSL). You can use connect(3SOCKET) on a connectionless endpoint to set the default destination address for datagrams. You can send data using connect(3SOCKET).

t_rcvconnect(3NSL)

-

t_listen(3NSL)

listen(3SOCKET)

t_listen(3NSL) waits for connection indications. listen(3SOCKET) sets the queue depth.

t_accept(3NSL)

accept(3SOCKET)

t_snd(3NSL)

send(3SOCKET)

sendto(3SOCKET)

sendmsg(3SOCKET)

sendto(3SOCKET) and sendmsg(3SOCKET) operate in connection mode as well as in datagram mode.

t_rcv(3NSL)

recv(3SOCKET)

recvfrom(3SOCKET)

recvmsg(3SOCKET)

recvfrom(3SOCKET) and recvmsg(3SOCKET) operate in connection mode as well as datagram mode.

t_snddis(3NSL)

-

t_rcvdis(3NSL)

-

t_sndrel(3NSL)

shutdown(3SOCKET)

t_rcvrel(3NSL)

-

t_sndudata(3NSL)

sendto(3SOCKET)

recvmsg(3SOCKET)

t_rcvuderr(3NSL)

-

read(2), write(2)

read(2), write(2)

In XTI/TLI you must push the tirdwr(7M) module before calling read(2) or write(2). In sockets, calling read(2) or write(2) suffices.

 
 
 
  Previous   Contents   Next