[comp.sys.mac.programmer] AT Socket Installation

queloz@bernina.ethz.ch (Ronald Queloz) (05/23/91)

I want to see how a piece of software (CDEV/INIT) I wrote spreads in
on our AppleTalk network. I thought I could install an AppleTalk
socket (with name and type) at initialization time (INIT). Then I 
could use a network utility like InterPoll to see where my software
has been gone to.

Now my question: Is there a simple way to install a AT socket which
does no communication at all. What Routine do I have to pick, what are
the parameters?

Many thank in advance!


Ronald B. Queloz

peirce@outpost.UUCP (Michael Peirce) (05/25/91)

In article <1991May23.130616.10046@bernina.ethz.ch>, queloz@bernina.ethz.ch (Ronald Queloz) writes:
> I want to see how a piece of software (CDEV/INIT) I wrote spreads in
> on our AppleTalk network. I thought I could install an AppleTalk
> socket (with name and type) at initialization time (INIT). Then I 
> could use a network utility like InterPoll to see where my software
> has been gone to.
> 
> Now my question: Is there a simple way to install a AT socket which
> does no communication at all. What Routine do I have to pick, what are
> the parameters?

Here's some general code you could adapt.  Note that the DataBlockP
is a pointer to a record allocated in the system heap.  It must be
on the system heap since the NBP name buffer must not move while the
name is registered (forever in your case).  ALL permanent storage
is part of this data record.

PROCEDURE GoOnline;
VAR
	nameCount	: integer;
	theNBPType	: str255;
	countStr	: str255;
BEGIN {GoOnline}
	WITH DataBlockP^ DO BEGIN
		WITH theATPPB DO BEGIN
			atpsocket := 0; {ask for any available}
			addrBlock.aNet		:= 0;
			addrBlock.aNode		:= 0;
			addrBlock.aSocket	:= 0;
		END;
		IF POpenATPSkt(@theATPPB,kSYNC) <> noErr
			THEN DebugStr('POpenATPSkt');
		mySocket := theATPPB.atpSocket;
		userName   := GetString(-16096);
		theNBPType := GetString(-4096)^^;
		serverName	:= userName^^; 
		nameCount	:= 1;
		REPEAT
			NBPSetNTE(@entityBuff,serverName,
					theNBPType,'*',mySocket);
			WITH theMPPPB DO BEGIN
				EntityPtr	:= @entityBuff;
				Interval		:= 3;
				count			:= 3;
				verifyFlag		:= $FF; 
			END;			
			stat := PRegisterName(@theMPPPB,kSYNC);
			IF stat = nbpDuplicate
				THEN BEGIN
					nameCount := nameCount + 1;
					HLock(Handle(userName));
					NumToString(nameCount,countStr);
					serverName := concat(userName^^,
									' [',countStr,']');
					HUnlock(Handle(userName));
				END;
		UNTIL stat <> nbpDuplicate;
		IF stat <> noErr
			THEN BEGIN
				DebugStr('PRegisterName');
			END;
{
%%% Skip this part since you don't want to read, of course you
	 could hang a read here and respond with version information...
}
		WITH inATPPB.realATPPB DO BEGIN
			atpSocket  := mySocket;
			reqLength  := SIZEOF(PacketRec);
			reqPointer := @inPacket;
			numOfBuffs := 1;
			ioCompletion := codeH^;
		END;
		inATPPB.dataPtr := LongInt(DataBlockP);
		IF PGetRequest(@inATPPB.realATPPB,kASYNC) <> noErr
			THEN DebugStr('PGetRequest');
	END;
END; {GoOnline}

--  Michael Peirce         --   outpost!peirce@claris.com
--  Peirce Software        --   Suite 301, 719 Hibiscus Place
--  Macintosh Programming  --   San Jose, California 95117
--           & Consulting  --   (408) 244-6554, AppleLink: PEIRCE

glenn@gla-aux.uucp (Glenn Austin) (05/28/91)

In article <1991May23.130616.10046@bernina.ethz.ch>, queloz@bernina.ethz.ch (Ronald Queloz) writes:
> Now my question: Is there a simple way to install a AT socket which
> does no communication at all. What Routine do I have to pick, what are
> the parameters?

Why not register an NBP name?  That would be simpler.

===============================================================================
| Glenn L. Austin                | "Turn too soon, run out of room.           |
| Macintosh Wizard and           |    Turn too late, much better fate."       |
| Auto Racing Driver             |   -- Jim Russell Racing School Instructors |
|-----------------------------------------------------------------------------|
| Usenet:  glenn@gla-aux.uucp         | CI$:       76354,1434                 |
| GENie:   G.AUSTIN3                  | AOnline:   GAustin                    |
===============================================================================