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 20 - Initializing and Closing Open Transport Reference /


The TNetBuf Structure

You use a TNetbuf structure to specify the location and size of a buffer that contains an address, option information, or user data. Provider functions use TNetbuf structures both as input parameters and output parameters. If you use a TNetbuf structure as an input parameter, you specify the location and size of a buffer containing information you want to send. If you use a TNetbuf structure as an output parameter, you specify the location and the maximum size of the buffer used to hold information when the function returns.

You use a TNetbuf structure to describe the location and size of contiguous data. Open Transport allows you to describe noncontiguous data with the OTData structure. For more information, see "Advanced Topics Reference"

The TNetbuf structure is defined by the TNetbuf data type.

struct TNetbuf {
   UInt32   maxlen;
   UInt32   len;
   UInt8*   buf;
};
typedef struct TNetbuf TNetbuf;
Field Description
maxlen
The size (in bytes) of the buffer to which the buf field points. You must set the maxlen field before passing a TNetbuf structure to a provider function as an output parameter. Open Transport ignores this field if you pass the TNetbuf structure as an input parameter.
len
The actual length (in bytes) of the information in the buffer to which the buf field points. If you are using the TNetbuf structure as an input parameter, you must set this field.
If you pass the TNetbuf structure as an output parameter, on return the provider function sets this field to the number of bytes the function has actually placed in the buffer referenced by the buf field.
buf
A pointer to a buffer. You must make sure that the buf field points to a valid buffer and that the buffer is large enough to store the information for which it is intended.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
15 JAN 1998