Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Networking With Open Transport / Part 1 - Open Transport Essentials
Chapter 4 - Endpoints


About Endpoints

An endpoint is the communications path between your application and an endpoint provider, which is a layered set of protocols that define how data and other information are exchanged between you and a remote client. The endpoint consists of a set of data structures, maintained by Open Transport, that specify the components of the endpoint provider and the manner in which the provider is to operate. In the process of opening an endpoint, you configure the endpoint provider and specify the protocol or set of protocols you want to use to transfer data and, if required, the hardware link. The section "Configuring and Opening a Provider" explains how you specify the software and hardware support your application requires. Whether you specify a single protocol or a layered set of protocols, the type of service provided by the highest-level protocol defines the type of the endpoint. For example, if you specify the AppleTalk Transaction Protocol (ATP), which offers connectionless transaction-based service, the endpoint is a connectionless transaction-based endpoint.

When you open an endpoint, Open Transport creates a data structure that contains information about the services the endpoint provider offers, the limits on the size of data it can send and receive, the size of internal buffers used to hold data, the current state of the endpoint, and so on. Open Transport obtains this information from the particular protocol implementations that you specify when you configure the endpoint provider. You can access information in some fields of this structure by calling functions that return information about the endpoint provider. Other fields of the structure are private and can be accessed only by Open Transport.

Opening an endpoint also creates an endpoint reference, a number that uniquely identifies this endpoint and that you must specify when calling any function relating to this endpoint.

Before you can use the endpoint to transfer data, you must bind the endpoint--that is, you must associate the endpoint with a protocol address. Depending on the protocol you use, you can specify this address as a symbolic name or as a network address. Specific address binding rules and address formats also vary with the protocol you use. In general, you cannot bind more than one connectionless endpoint to an address, but you can bind several connection-oriented endpoints to a single address.

Open Transport functions that you can use only with endpoints are called endpoint functions. You use endpoint functions to create and bind an endpoint, to obtain information about an endpoint, to establish and break down connections, and to transfer data. What functions you can call for an endpoint depend on the type of the endpoint and on its state. The behavior of a function is determined by the endpoint's mode of operation. In order to write Open Transport applications that behave in a reliable and predictable manner, it is important that you understand how these factors affect the behavior of an endpoint provider. This section describes the different types of endpoints, describes the effect of an endpoint's mode of operation on the behavior of endpoint functions, and explains how Open Transport uses information about endpoint states to manage endpoints.

Endpoint Types and Type of Service

There are four types of endpoints, each offering a different type of service:

The chapter "Introduction to Open Transport" defines and describes the different services that each protocol offers and explains some of the criteria you might use for selecting a specific type. The documentation for the protocol you are using provides information about how a type of service is implemented for your endpoint and the options that you can use to fine-tune its behavior. The section "Using Endpoints" describes how you use endpoint functions to implement these services. However, before you read that section, you might find it helpful to understand the naming conventions used for endpoint functions because these are directly related to an endpoint's type of service. These conventions are described in the next section.

Naming Conventions for Endpoint Functions

You can use endpoint functions that return information about the endpoint's state, address, or modes of execution with all endpoint types. However, the type of the endpoint determines which endpoint functions you can call to transfer data. There is no single function that you can use to send data or to receive data. For example, when you send data using a connectionless transactionless endpoint, you call the OTSndUData function; when you send data using a connection-oriented transactionless endpoint, you call the OTSnd function. Table 4-1 presents a summary of the function names for functions used to transfer data. The functions are grouped together based on the endpoint's type of service.

Table 4-1 The names of functions used to transfer data
 ConnectionlessConnection-oriented
TransactionlessOTSndUData

OTRcvUData

OTRcvUDErr

OTSnd

OTRcv

Transaction-basedOTSndURequest

OTRcvURequest

OTSndUReply

OTRcvUReply

OTCancelURequest  

OTCancelUReply

OTSndRequest

OTRcvRequest

OTSndReply

OTRcvReply

OTCancelRequest

OTCancelReply

The following bulleted items explain the5 conventions used to name the different groups of functions:

Of course, you can use the functions that establish and tear down connections only with connection-oriented endpoints. These functions suggest their use in their names: for example, OTConnect or OTSndDisconnect.

Connection-oriented endpoints support two kinds of disconnects: abortive disconnects and orderly disconnects. An abortive disconnect breaks a connection immediately, even if this were to result in loss of data; an orderly disconnect (or "orderly release") allows an endpoint to send all data remaining in its send buffer before it breaks a connection. These two kinds of disconnects are reflected in the names of the functions used: OTSndDisconnect for an abortive disconnect and OTSndOrderlyDisconnect for an orderly disconnect.

Endpoint Options

The goal of Open Transport is to abstract basic types of service offered by network protocols. For example, ADSP and TCP both offer connection-oriented transactionless service. As a result, changing the endpoint to a different protocol (but one that provides the same type of service) would require minimal changes to the application and consequently make your application virtually independent of the underlying transport used to transfer data. Achieving transport independence, however, also means being willing to forego any special advantages or features that a protocol has to offer. If it is not possible for you to do without these features, you can use options to take advantage of protocol-specific features.

An option is a value you can set for an endpoint, to link the behavior of the provider more closely to a specific protocol. By using options, you can take advantage of a feature that is unique to a protocol.

In general, the use of options decreases the transport independence of your application. When you open an endpoint, the endpoint provider creates a buffer containing default option values that it chooses to ensure maximum portability across protocol families. It is recommended that you use these values rather than setting different values. However, if you need to customize transport services, you might need to specify different option values. Selecting alternate option values begins a process called option negotiation. Besides noting those instances in which you can specify option information when calling endpoint functions, this chapter provides no information about options. For detailed information about options and for a description of the OTOptionManagement endpoint function, see "Option Management".

Modes of Operation

An endpoint provider, like other Open Transport providers, can also be characterized by its mode of operation, which determines

The chapter "Providers" explains these concepts and describes the functions you use to get and set a provider's mode of operation.

One thing to keep in mind is that not all endpoint functions operate differently in asynchronous mode. Those functions that do behave differently are listed in Table 4-2. For each function, the table lists the corresponding completion event.

Table 4-2 Endpoint functions that behave differently in synchronous and asynchronous modes
FunctionCompletion event
OTOptionManagementT_OPTIONMANGEMENTCOMPLETE
OTBindT_BINDCOMPLETE
OTUnbindT_UNBINDCOMPLETE
OTAcceptT_ACCEPTCOMPLETE
OTSndRequestT_REQUESTCOMPLETE
OTSndReplyT_REPLYCOMPLETE
OTSndURequestT_REQUESTCOMPLETE
OTSndUReplyT_REPLYCOMPLETE
OTSndDisconnectT_DISCONNECTCOMPLETE
OTGetProtAddressT_GETPROTADDRCOMPLETE
OTResolveAddressT_RESOLVEADDRCOMPLETE

Endpoint States

Each endpoint has an attribute known as its endpoint state. An endpoint state governs which endpoint functions you can call for the endpoint. For example, if you open an endpoint but do not bind it, it is in the T_UNBND state and the only two functions you can call for the endpoint are OTCloseProvider or OTBind.

The endpoint's type of service determines the possible states an endpoint can be in while it is transferring data. For example, a connectionless endpoint can only transfer data while it is in the T_IDLE state, and a connection-oriented endpoint can only transfer data while it is in the T_DATAXFER state. Table 4-3 describes possible endpoint states for connectionless and connection-oriented endpoints and suggests in parentheses an English equivalent for the name of each constant.

Table 4-3 Endpoint states
StateMeaning
T_UNINIT Uninitialized. This endpoint has been closed and destroyed or has not been created.
T_UNBNDUnbound. This endpoint is initialized but has not yet been bound to an address.
T_IDLEIdle. This endpoint has been bound to a local protocol address and is ready for use. Connectionless endpoints can send or receive data; connection-oriented endpoints can initiate or listen for a connection.
T_OUTCONOutgoing connection request. This connection-oriented endpoint has initiated a connection and is waiting for the remote peer to accept the connection.
T_INCONIncoming connection request. This connection-oriented endpoint has received a connection request but has not yet accepted or rejected the request.
T_DATAXFER Data transfer. This connection-oriented endpoint can now transfer data because the connection has been established.
T_OUTRELOutgoing release request. This connection-oriented endpoint has issued an orderly disconnect that the remote peer has not acknowledged. The endpoint can continue to read data but must not send any more data.
T_INREL Incoming release request. This connection-oriented endpoint has received a request for an orderly disconnect, which it has not yet acknowledged. The endpoint can continue to send data until it acknowledges the disconnection request, but it must not read data.

Figure 4-1 shows a diagram illustrating the possible endpoint states for a connectionless endpoint.

Figure 4-1 Typical endpoint states for a connectionless endpoint

A connectionless endpoint can be in one of three states: T_UNINIT,T_UNBND, or T_IDLE. Before you open the endpoint, it is in the T_UNINIT state. After you open the endpoint but before you bind it, it is in the T_UNBND state. After you bind the endpoint, it is in the T_IDLE state and is ready to transfer data. A connectionless transactionless endpoint would use the OTSndUData or OTRcvUData functions to transfer data; a connectionless transaction-based endpoint would use the OTSndURequest, OTRcvURequest, OTSndUReply, and OTRcvUReply functions to transfer data. When the endpoint finishes transferring data, you must first unbind the endpoint--that is, dissociate the endpoint from its address. At this stage, the endpoint returns to the T_UNBND state. Then you can close the endpoint, at which time the endpoint returns to the T_UNINIT state.

Figure 4-2 shows a state diagram illustrating the possible endpoint states for a connection-oriented endpoint.

Figure 4-2 Possible endpoint states for a connection-oriented endpoint

Like a connectionless endpoint, a connection-oriented endpoint is in the T_UNINIT state until you open it and then in the T_UNBND state until you bind it. After you bind an endpoint but before you inititate a connection, an endpoint is in the T_IDLE state.

During the connection process, the endpoint provider initiating the connection, known as the active peer, calls the OTConnect function to request a connection. At this point, the active peer is in the T_OUTCON state. The endpoint provider listening for a connection request, known as the passive peer, calls the OTListen function to read an incoming request. After it has read the request, the passive peer changes to the T_INCON state. It can now either accept the connection using the OTAccept function or reject the connection using the OTSndDisconnect function (not shown in Figure 4-2). If the endpoint accepts the connection, it changes to the T_DATAXFER state; if it rejects the connection it goes back to the T_IDLE state.

The active peer must acknowledge the response using the OTRcvConnect function (for a connection that has been accepted) or the OTRcvDisconnect function (for a connection that has been rejected). Calling the OTRcvConnect function establishes the connection and places the active peer in the T_DATAXFER state. Calling the OTRcvDisconnect function rejects the connection and places the active peer in the T_IDLE state (not shown in Figure 4-2). After they are connected, endpoints can transfer data using simple send and receive operations or using transaction requests and replies, depending on whether the endpoint is transactionless or transaction-based.

When you have finished transferring data, you should tear down the connection by using an orderly disconnect process if possible. That is, you should check to see whether the protocol supports an orderly disconnect. If it does, you initiate this process by calling the OTSndOrderlyDisconnect function. This places the calling endpoint in the T_OUTREL state. It also creates a pending T_ORDREL event for the other endpoint. The endpoint to which you have sent the disconnection request can become aware of the event by means of a notifier function or by calling the OTLook function. It must then acknowledge receiving the disconnection request by calling the OTRcvOrderlyDisconnect function. Then it must tear down its side of the connection by also calling the OTSndOrderlyDisconnect function, which you must also acknowledge. Disconnecting the endpoints places them in the T_IDLE state again, and you can reconnect or close them.

Note
It is not required that the active peer in the disconnect phase be the same as the active peer in the connect phase.
Open Transport uses endpoint state information to manage endpoints. Consequently, it is crucial that you call functions in the right sequence and that you call functions to acknowledge receipt of data as well as of connection and disconnection requests. Sending these acknowledgments is necessary to leave the endpoint in an appropriate state for further processing.

Table 4-4 lists the functions that can change an endpoint's state and specifies what the resulting state is depending on whether the function succeeds or fails.

Table 4-4 Functions that can change an endpoint's state
FunctionValid state before callsState after call
if call succeedsif call fails
OTOpenEndpointT_UNINITT_UNBNDn/a
OTAsyncOpenEndpointT_UNINITT_UNBNDn/a
OTBindT_UNBNDT_IDLET_UNBND
OTUnbindT_IDLET_UNBND
OTGetEndpointInfoany but T_UNINIT
OTGetEndpointStateany but T_UNINIT
OTLookany but T_UNINIT
OTGetProtAddressany but T_UNINIT 
OTResolveAddressany but T_UNINIT  
OTSyncany but T_UNINIT 
OTAllocany but T_UNINIT  
OTFreeany but T_UNINIT  
OTCountDataBytesT_IDLE  
OTSndUDataT_IDLE  
OTRcvUDErrT_IDLE  
OTRcvUDataT_IDLE  
OTSndURequestT_IDLE  
OTSndUReplyT_IDLE  
OTRcvUReplyT_IDLE  
OTCancelURequestT_IDLE  
OTCancelUReplyT_IDLE  
OTConnectT_IDLET_OUTCONT_IDLE
OTListenT_IDLE, T_INCON  
OTAccept

--destination

 

--source

 

T_IDLE, T_UNBND

 

T_INCON

 

T_DATAXFER

 

T_INCON
T_IDLE

 

T_IDLE, T_UNBND

 

T_INCON

OTSndT_DATAXFER, T_INREL  
OTRcvT_DATAXFER, T_OUTREL  
OTSndRequestT_DATAXFER, T_INREL  
OTRcvRequestT_DATAXFER, T_OUTREL  
OTSndReplyT_DATAXFER, T_OUTREL    
OTRcvREplyT_DATAXFER, T_INREL  
OTCancelRequestT_DATAXFER  
OTCancelReplyT_DATAXFER  
OTSndDisconnectT_DATAXFER, T_INREL,
T_OUTCON, T_OUTREL

T_INCON

T_IDLE


T_IDLE, T_INCON

state before call

T_INCON

OTRcvDisconnectT_DATAXFER, T_INREL,
T_OUTCON, T_OUTREL

T_INCON

T_IDLE


T_IDLE, T_INCON  

state before call

T_INCON

OTSndOrderlyDisconnectT_DATAXFER

T_INREL

T_OUTREL

T_IDLE

T_DATAXFER

T_INCON

OTRcvOrderlyDisconnect  T_DATAXFER

T_OUTREL

T_INREL

T_IDLE

T_DATAXFER

T_OUTREL

The arrival of an asynchronous event can also change the state of an endpoint. Table 4-5 shows the state of the endpoint before the event is received and the state of the endpoint after the event is consumed. An event is consumed or cleared when your application acknowledges receipt of the event. For example, if you get a T_LISTEN event, you call the OTListen function; after you get a T_DISCONNECT event, you call the OTRcvDisconnect function.

Table 4-5 Events that can change an endpoint's state
Old stateEventNew stateConsuming function
T_IDLET_LISTENT_INCONOTListen
T_IDLET_CONNECTT_DATAXFEROTRcvConnect
T_IDLE
T_UNBND
T_PASSCONT_DATAXFER  none
T_OUTCON T_DATAXFER T_OUTREL T_INREL  T_DISCONNECT  T_IDLEOTRcvDisconnect
T_DATAXFERT_ORDRELT_INRELOTRcvOrderlyDisconnect
T_INCONT_DISCONNECTT_IDLE
T_INCON
OTRcvDisconnect

The section "Handling Events for Endpoints" lists the asynchronous events that a provider can issue and the functions you must call to clear these events.

Transport Service Data Units

The main purpose of endpoints is to transfer data. The terms transport service data unit and expedited transport service data unit are used to describe the size and kind of data that a particular endpoint can handle when it is transferring data in discrete units known as datagrams. Not all protocols use transport service data units to transfer data.

A transport service data unit (TSDU) refers to the largest piece of data that an endpoint can transfer with boundaries and content preserved unchanged. Different types of endpoints and different endpoint implementations support different size TSDUs.

An expedited transport service data unit (ETSDU), refers to the largest piece of expedited data than an endpoint can transfer. Expedited data is considered to be urgent. Not all endpoint providers can transfer expedited data. Usually, connection-oriented and transaction-based endpoints require the use of expedited data for control or attention messages, and therefore the implementation of these types of endpoints often supports the transfer of expedited data.

Three special constants are used to specify information about TSDUs and ETSDUs:

For additional information, see "The TEndpointInfo Structure".

When you open an endpoint, Open Transport creates an endpoint information structure, a TEndpointInfo structure, that you can examine to find out whether the endpoint supports normal or expedited data and the maximum size of this data. The section "Obtaining Information About E ndpoints" explains how you examine this structure to find out this information.


Subtopics
Endpoint Types and Type of Service
Naming Conventions for Endpoint Functions
Endpoint Options
Modes of Operation
Endpoint States
Transport Service Data Units

Previous Book Contents Book Index Next

© Apple Computer, Inc.
15 JAN 1998