OTAccept
Accepts an incoming connection request.C INTERFACE
OSStatus OTAccept(EndpointRef ref, EndpointRef resRef, TCall* call);C++ INTERFACE
OSStatus TEndpoint::Accept(EndpointRef resRef, TCall* call);PARAMETERS
ref- The endpoint reference of the listening endpoint.
resRef- The endpoint reference of the endpoint accepting the connection.
call- A pointer to a
TCallstructure (page 3-62) that contains information about the address of the peer requesting the connection, option information, data associated with
the connection request, and the connection ID for this connection.DESCRIPTION
You use theOTAcceptfunction to accept a request that you retrieved using theOTListenfunction. You can accept a connection on either the same or on a different endpoint than the one listening for connection request.
If you do not wish to accept the request, you must call the
- If you accept the connection on the same endpoint (the values of the
refandresRefparameters are the same), there must be no other outstanding connection requests on that endpoint. Otherwise, the call toOTAcceptfails and returns thekOTIndOutErrresult.- If you accept the connection on a different endpoint (the values of the
refandresRefparameters are different), you are not required to bind the endpoint accepting the request first. If the endpoint is not bound, the provider binds it to the same address as that of the endpoint receiving the connection request. If you want to bind it explicitly to that address, you must set thereqAddr->qlenfield to 0 and the endpoint must be in theT_IDLEstate before calling theOTAcceptfunction. If you want to bind it to a different address, there are no restrictions on the value of theeqAddr->qlenfield.
OTSndDisconnectfunction.If the endpoint is in asynchronous mode, the
OTAcceptfunction returns immediately with akOTNoErrorresult, indicating that processing has begun and that the client will be notified when it is complete.When processing is finished and the connection is opened, the provider for the endpoint specified by the
refparameter, calls that endpoint's notifier, passingT_ACCEPTCOMPLETEfor thecodeparameter andkInvalidEndpointReffor thecookieparameter. The provider for the endpoint specified by theresRefparameter, calls that endpoint's notifier, passingT_PASSCONfor thecodeparameter andreffor thecookieparameter. If you have accepted the connection on the same endpoint (refandresRefare the same), the provider issues theT_ACCEPTCOMPLETEevent first, and then theT_PASSCONevent.If you have not installed a notifier, you can poll the endpoint accepting the connection for a change of state to
T_DATAXFER; the change of state happens when the connection is opened.SPECIAL CONSIDERATIONS
In asynchronous mode, it is possible for the endpoint to issue theT_ACCEPTCOMPLETEevent before theOTAcceptfunction returns thekOTNoErrorresult.Not all endpoints support the sending of data with a connection request. Examine the
connectfield of theTEndpointInfostructure for the endpoint to determine if the endpoint supports the sending of data and the maximum size of the data.The
OTAcceptfunction fails with thekOTLookErrerror if there are indications (T_DISCONNECTorT_LISTEN) waiting to be received. This is becauseCalling the
OTAcceptfunction on an endpoint that was bound with aqlengreater than 1 can result in akOTLookErrbeing returned because anotherT_LISTENevent has arrived. Unfortunately, XTI specifies that the accept request cannot be acted on until theOTListenfunction has been called to receive this new connection request. This effectively means that you need to keep an array of outstanding connection requests. If you are acting onT_LISTENevents in your notifier, then you need to be able to handle having as many outstanding connection requests as you indicate in theqlenfield, issuing an accept request, and getting aT_LISTENCOMPLETEevent before theT_ACCEPTCOMPLETEevent returns to you.COMPLETION EVENT CODES
T_ACCEPTCOMPLETE0x20000003 The OTAcceptfunction has completed. Thecookieparameter of the notifier function contains the endpoint reference of the endpoint to which the connection has been passed.VALID STATES
Endpoint specified by therefparameter:T_INCONEndpoint specified by the
resRefparameter:T_IDLEorT_UNBNDSEE ALSO
You use theOTListenfunction (page 3-125) to read a connection request before calling theOTAcceptfunction to accept the request.You use the
TCallstructure (page 3-62) to store information about the address of the peer requesting the connection, option information, data associated with the connection request, and the connection ID for this connection.You use the
OTBindfunction (page 3-77) to bind the endpoint accepting the request explicitly and to specify the number of connection requests that can be outstanding for the endpoint.You use the
OTSndDisconnectfunction (page 3-149) to reject an incoming connection request.For information on how to use this function with a TCP/IP protocol, see page 8-18 in the TCP/IP 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