OTConnect
Requests a connection to a remote peer.C INTERFACE
OSStatus OTConnect(EndpointRef ref, TCall* sndCall, TCall* rcvCall);C++ INTERFACE
OSStatus TEndpoint::Connect(TCall* sndCall, TCall* rcvCall);PARAMETERS
ref- The endpoint reference of the endpoint initiating the connection.
sndCall- A pointer to a
TCallstructure (page 3-62) that specifies the address of the remote peer, any data transmitted when establishing a connection, and any options for this connection.rcvCall- A pointer to a
TCallstructure (page 3-62) that specifies the address of the peer that has accepted the connection, the value of options proposed using thesndCallparameter, and any data transmitted by the peer accepting the connection.- This parameter is only meaningful for synchronous calls to the
OTConnectfunction.DESCRIPTION
If the endpoint is in synchronous mode, theOTConnectfunction returns after the connection is established and fills in the fields of theTCallstructure (referenced by thercvCallparameter) with the actual values associated with this connection. These might be different from the values you specified using thesndCallparameter.If the
OTConnectfunction returns with thekOTLookErrresult, this might be either because of a pendingT_LISTENorT_DISCONNECTevent. That is, either a connection request from another endpoint has interrupted execution of the function, or the remote endpoint has rejected the connection. If you don't have a notifier installed, you can call theOTLookfunction to identify the event that caused thekOTLookErrresult. If the event isT_LISTEN, you must accept or reject the incoming request and then continue processing theOTConnectfunction by callingOTRcvConnect. If the event isT_DISCONNECT, you must call theOTRcvDisconnectfunction to clear the error condition--that is, to deallocate memory and place the endpoint in the correct state.If the endpoint is in asynchronous mode, the
OTConnectfunction returns before the connection is established with akOTNoDataErrresult to indicate that the connection is in progress. When the connection is established, the endpoint provider calls your notifier, passingT_CONNECTfor thecodeparameter. In response, you must call theOTRcvConnectfunction to read the connection parameters that would have been returned using thercvCallparameter if the endpoint were in synchronous mode.It is possible that the remote address returned in the
addrfield of thercvCallparameter is not the same as the address you requested using thesndCall->addrfield. This happens when the connection is accepted for a different endpoint than the one receiving the connection request.If the
OTConnectfunction returns a result other thankOTNoDataErr, then the connection attempt has not been initiated and no events will be received.SPECIAL CONSIDERATIONS
Not all endpoints support the sending of data with a connection request. Examine theconnectfield of theTEndpointInfostructure for the endpoint to determine if the endpoint supports the sending of data and to determine the maximum size of the data.VALID STATES
T_IDLESEE ALSO
You can use theOTLookfunction (page 3-85) to retrieve a pending
asynchronous event.You use a
TCallstructure (page 3-62) to specify the address of the remote peer, any data transmitted when establishing a connection, and any options for the connection.You use the
OTRcvDisconnectfunction (page 3-151) to acknowledge that your request for a connection has been rejected.For information on how to use this function with a TCP/IP protocol, see page 8-17 in the TCP/IP chapter.
For information on how to use this function with AppleTalk protocols, see page 13-10 in the ADSP chapter and page 15-9 in the PAP chapter.
You examine the
connectfield of theTEndpointInfostructure (page 3-48) to determine whether your endpoint supports the sending of data with a connection request.
Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help