Important: The information in this document is obsolete and should not be used for new development.
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 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.
- The
call->addr.buffield points to a buffer that contains the address of the peer that requested the connection. The provider may optionally check this address to ensure you're accepting the right connection. If you do not want to specify a value, set thecall->addr.lenfield to 0.
- The
call->opt.buffield points to a buffer that contains option values for this connection. If you do not want to specify any options set thecall->opt.lenfield to 0.
- The
call->udata.buffield points to a buffer containing any data to be returned to the endpoint requesting the connection. Thecall->udata.lenfield specifies the length of the data.
- The
call->sequencefield specifies the connection ID of the connection request that you are accepting. This must be the same value that was passed to you by theOTListenfunction when you received the connection request.
- function result
- An error code. See Discussion.
DISCUSSION
You use theOTAcceptfunction to accept a request that you retrieved using theOTListenfunction. You can accept a connection on either the same or a different endpoint than the one listening for connection request.
If you do not wish to accept the connection 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.
OTSndDisconnectfunction.If the endpoint is in synchronous mode, the function does not return until the operation is complete. 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, passing the eventT_ACCEPTCOMPLETEfor thecodeparameter and the endpoint reference (ref) for thecookieparameter. The provider for the endpoint specified by theresRefparameter calls that endpoint's notifier, passingT_PASSCONfor thecodeparameter andresReffor 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
- Note
- It is possible, in the case where the listening and accepting endpoints are different, that the accepting endpoint receives a
T_DATAevent before receiving theT_PASSCONevent. If this happens, set a flag to defer receiving the data until later. When theT_PASSCONevent is received, check the flag and issue theOTRcvcall if the flag is set. Note that after deferring the handling of theT_DATAevent, your handler will not be notified of this event again, until you read all of the data presently available.![]()
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 the resultkOTNoError.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.Calling the
OTAcceptfunction on an endpoint that was bound with aqlengreater than 1 can result in the resultkOTLookErrbeing returned because anotherT_LISTENevent orT_DISCONNECTevent has arrived. For information on how to handle this situation, see "Handling Multiple Simultaneous Connections".SEE ALSO
TheOTBindfunction.