[comp.sys.mac] AppleTalk programming question

peirce@lll-crg.llnl.gov (Michael Peirce) (11/15/87)

'
    I've been messing around with AppleTalk, or rather, trying to.
    
    I can get things to work: once.  The first time I run the program
    things are fine and act as they should, but the second time BOMB!
    
    If anyone can suggest something, I'd really appreciate it.  Below is
    a simple program that exhibits this behavior...
    
    -- michael
-------------------------------------------------------------------------------
#include "stdio.h"
#include "Appletalk.h"

/*
 *		LightSpeed C project contains the following libraries:
 *			AppleTalk.lib
 *			MacTraps
 *			stdio
 *			test.at.c
 *
 *		You also need a resource file containing the 'atpl' resource found in
 *		the file :LightSpeed C:Mac Libraries:Resource Files:ATalk/ABPackage
 *		(this seems to contain the glue from Think for AppleTalk.
 *
 *
 *				Run it once and it seems to work just fine,
 *				but run it a second time and KAPLOWEE!!!
 *
 */

RetransType	retrans = { 2, 2 };
EntityName	who		= { "\p=", "\p=", "\p*"};
ABRecHandle	myABRec;
OSErr		stat;
char		buff[255];

main ()
{

	/*
	 *	Check to see if the drivers are open.
	 */

	printf("IsMMPOpen %d\n",IsMPPOpen());
	printf("IsATPOpen %d\n",IsATPOpen());

	/*
	 *	Open up the AppleTalk drivers (if already open, that's OK)
	 */
	 
	stat = MPPOpen();

	printf("stat from MPPOpen was %d\n",stat);
	
	/*
	 *	Ask the Name Binding Protocal who's out there...
	 */
	 
	myABRec = (ABRecHandle)NewHandle(nbpSize);

	(**myABRec).nbpProto.nbpEntityPtr		= &who;
	(**myABRec).nbpProto.nbpBufPtr			= buff;
	(**myABRec).nbpProto.nbpBufSize			= 255;
	(**myABRec).nbpProto.nbpDataField		= 10;
	(**myABRec).nbpProto.nbpRetransmitInfo	= retrans;
	
	stat = NBPLookup(myABRec,/* ASYNC => */FALSE);
	
	printf("stat from NBPLookUp was %d   count = %d\n",stat,(**myABRec).nbpProto.nb
pDataField);


	stat = MPPClose();

	printf("stat from MPPClose was %d\n",stat);

}

singer@endor.harvard.edu (Richard Siegel) (11/15/87)

In article <1292@lll-lcc.aRpA> peirce@lll-crg.llnl.gov.UUCP (Michael Peirce) writes:
>'
>    I've been messing around with AppleTalk, or rather, trying to.
>    
>    I can get things to work: once.  The first time I run the program
>    things are fine and act as they should, but the second time BOMB!
>    
	The problem was with the glue and ATPL resource supplied to us
by Apple. The new AppleTalk glue supplied as part of the 2.13 update
does not require the ATPL resource and functions properly.

		-_Rich

**The opinions stated herein are my own opinions and do not necessarily
represent the policies or opinions of my employer (THINK Technologies, Inc).

* Richard M. Siegel | {decvax, ucbvax, sun}!harvard!endor!singer    *
* Customer Support  | singer@endor.harvard.edu			    *
* Symantec, THINK Technologies Division.  (No snappy quote)         *