Important: The information in this document is obsolete and should not be used for new development.
Acquiring and Removing Multinodes
You can add an AppleTalk multinode once the physical node that runs your application has connected to the AppleTalk network and AppleTalk has assigned to it a user node ID. After you are finished using the multinode, your application must remove it. This section describes how to do these tasks.To acquire a multinode address, perform the following steps:
From assembly language, you can directly make an
- Use the Device Manager's
OpenDriverfunction to open the .MPP driver.
- The .MPP driver must be opened before you call the multinode routines. The
OpenDriverfunction call returns the .MPP driver's reference number.- Save the returned value because you must supply this reference number as an input parameter in the
ioRefNumfield of the multinode parameter block when you call the multinode routines.
- Create a receive routine to receive broadcast messages and packets addressed to your multinode. See "Receiving Packets Addressed to Your Multinode" beginning on page 12-10 for details.
- Allocate storage and set parameter block fields as needed.
- Define a multinode parameter block of type
MNParamBlock. Allocate storage for
a multinode parameter block that includes the fields required for theAddNoderoutine. See "The Multinode Parameter Block" on page 12-18.- You must set the
csCodeparameter block field to the numeric value of 262 for theAddNoderoutine. For the other required parameter block fields, see "AddNode" beginning on page 12-20.
- Call the
AddNoderoutine once for each multinode that you need.
- You can acquire only one multinode through each request. You can request a specific multinode address, and if that multinode is available, the .MPP driver will assign it to you. Otherwise, the .MPP driver will return a multinode address that
it selects randomly.- Because the
AddNoderoutine is not defined in the MPW interface files, you must call the Device Manager directly and execute theAddNoderoutine as an immediate synchronous control call.
immed _Controltrap macro call. To issue theAddNoderoutine as an immediate synchronous control call from a high-level language such as Pascal or C, you must define a function as part of your application. Listing 12-1 shows how to do this in the Pascal language.Listing 12-1 Defining a Pascal function that makes an immediate
AddNodecall
FUNCTION PBControlImmedSync(paramBlock: ParmBlkPtr): OSErr; INLINE $205F,$A204,$3E80; FUNCTION AddNode(thePBptr: MNParmBlkPtr): OSErr; CONST tryAddNodeAgainErr = -1021; VAR err: OSErr; BEGIN thePBptr^.csCode := 262; {addNode} thePBptr^.ioRefNum := mppUnitNum; {If the call returns tryAddNodeAgainErr, make the call repeatedly until it no longer returns this error.} REPEAT err := PBControlImmedSync(ParmBlkPtr(thePBptr)); UNTIL (err <> tryAddNodeAgainErr); AddNode := err; END;You must issue theAddNodecall synchronously because you need to callAddNoderepeatedly if the call returns an error of -1021, which indicates that the .MPP driver could not satisfy theAddNoderequest and that you should try the request again immediately.The .MPP driver internally associates the address of your receive routine with the multinode address that it returns to you. See "AddNode" beginning on page 12-20
for a complete description of this routine and the parameters that you must pass it.When you are finished using the multinode, you call the
RemoveNoderoutine to remove the multinode.
- Allocate nonrelocatable memory for a multinode parameter block that includes the fields required for the
RemoveNoderoutine. See "The Multinode Parameter Block" beginning on page 12-18. The multinode parameter block belongs to the .MPP driver for the life of theRemoveNodecall.- You issue the
RemoveNoderoutine as a Device Manager'sPBControlcall. See "RemoveNode" beginning on page 12-23 for details on this routine and the parameters it requires. You must specify thecsCodenumeric value 263 for theRemoveNoderoutine.