Important: The information in this document is obsolete and should not be used for new development.
OTGetProtAddress
Obtains the address to which an endpoint is bound and, if the endpoint is currently connected, also obtains the address of its peer.C INTERFACE
OSStatus OTGetProtAddress(EndpointRef ref, TBind* boundAddr, TBind* peerC++ INTERFACE
OSStatus TEndpoint::GetProtAddress(TBind* boundAddr, TBind* peerAddr);PARAMETERS
ref- The endpoint reference of the endpoint whose local and peer address is sought.
boundAddr- A pointer to a
TBindstructure. TheboundAddr->addrfield is aTNetBufstructure that returns the address of the endpoint specified by therefparameter. You must allocate a buffer for the address information and initialize theboundAddr.buffield to point to that buffer. You must also initialize theboundAddr.maxlenfield to the size of the address buffer.- If the endpoint is in the
T_UNBNDstate, the fieldboundAddr->addr.lenfield is set to 0.- If you are calling this function only to determine the address of the peer endpoint, you can set the
boundAddrparameter toNIL.- The
boundAddr->qlenfield is ignored.peerAddr- A pointer to a
TBindstructure. If the peer endpoint is currently connected or is in theT_DATAXFERstate, thepeerAddr->addrfield (aTNetbufstructure) returns the address of the endpoint's peer.- If you are calling this function only to determine the address to which the endpoint is bound, you can set the
pperAddrparameter tonil.- The
peerAddr->qlenfield is ignored. If the endpoint is not connected or in theT_DATAXFERstate, thepeerAddr->addr.lenfield is set to 0 and thepeerAddr->addr.bufpointer may be set toNULL.- function result
- An error code. See Discussion.
DISCUSSION
TheOTGetProtAddressfunction returns the address to which an endpoint is bound in theboundAddrparameter and, if the endpoint is currently connected, it returns the address of its peer in thepeerAddrparameter. Not all endpoints support this function. If theT_XPG4_1bit in theflagsfield of theTEndpointInfostructure is not set, the endpoint does not support this function.You are responsible for allocating the buffers required to hold the local and peer addresses. The
addrfield of theTEndpointInfostructure specifies the maximum amount of memory needed to store the address of an endpoint. Use this value as the size of the buffers.If the endpoint is in synchronous mode, the function returns when the operation is complete. If the endpoint is in asynchronous mode and a notification routine is installed, the function returns
kOTNoErrorand the provider sends the event codeT_GETPROTADDRCOMPLETE, when the operation completes. Theresultparameter iskOTNoErrorif the function succeeded or a negative error code if it did not. Thecookieparameter sent to the notification routine contains thepeerAddrvalue unless that isNULL. If thepeerAddrvalue wasNULL, thecookieparameter contains theboundAddrvalue instead. If a notifier is not installed, it is not possible to determine when the function completes. For more information on notifier codes and event codes, seeMyNotifierCallbackfunction and "Event Codes".SEE ALSO
TheOTAcceptfunction.