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 2 - Open Transport Reference
Chapter 22 - Endpoints Reference / Functions
Obtaining Information About an Endpoint /


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* peer
C++ 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 TBind structure. The boundAddr->addr field is a TNetBuf structure that returns the address of the endpoint specified by the ref parameter. You must allocate a buffer for the address information and initialize the boundAddr.buf field to point to that buffer. You must also initialize the boundAddr.maxlen field to the size of the address buffer.
If the endpoint is in the T_UNBND state, the field boundAddr->addr.len field is set to 0.
If you are calling this function only to determine the address of the peer endpoint, you can set the boundAddr parameter to NIL.
The boundAddr->qlen field is ignored.
peerAddr
A pointer to a TBind structure. If the peer endpoint is currently connected or is in the T_DATAXFER state, the peerAddr->addr field (a TNetbuf structure) 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 pperAddr parameter to nil.
The peerAddr->qlen field is ignored. If the endpoint is not connected or in the T_DATAXFER state, the peerAddr->addr.len field is set to 0 and the peerAddr->addr.buf pointer may be set to NULL.
function result
An error code. See Discussion.
DISCUSSION
The OTGetProtAddress function returns the address to which an endpoint is bound in the boundAddr parameter and, if the endpoint is currently connected, it returns the address of its peer in the peerAddr parameter. Not all endpoints support this function. If the T_XPG4_1 bit in the flags field of the TEndpointInfo structure 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 addr field of the TEndpointInfo structure 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 kOTNoError and the provider sends the event code T_GETPROTADDRCOMPLETE, when the operation completes. The result parameter is kOTNoError if the function succeeded or a negative error code if it did not. The cookie parameter sent to the notification routine contains the peerAddr value unless that is NULL. If the peerAddr value was NULL, the cookie parameter contains the boundAddr value 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, see MyNotifierCallback function and "Event Codes".

SEE ALSO
The OTAccept function.

Table 4-4 .


Previous Book Contents Book Index Next

© Apple Computer, Inc.
15 JAN 1998