{$DOUBLE}
{$NOWALKBACK$}
Program CONTST;

{ 
  Version x1.0
  File:[decnet]CONTST.PAS
  Author: Jim Bostwick  13-OCT-1989 

  Last Edit: 13-OCT-1989 02:48:32 

  History:


    This program is a connect test for the DECNET package.
 It builds a connect block, and then attempts to connect to 
 the specified task at the specified node. Status is reported.
 If the connection comes up, then we knock it down. Either way,
 we go away. 

}
{$Nolist}
{[a+,b+,l-,k+,r+] Pasmat }
 %INCLUDE 'PAS$EXT:General.typ';
 %INCLUDE 'PAS$EXT:DECNET.PKG';
 %INCLUDE 'PAS$EXT:STRING.PKG';
 %INCLUDE 'PAS$EXT:WAIT.EXT';
 %INCLUDE 'PAS$EXT:ALUN.EXT'; 
{$List }


VAR
    STAT, N: INTEGER;
    IOSB: IO_STATUS_BLOCK;
    CONB: NET_REQUEST_BLOCK;
    task, nul_msg, inmsg: CH16;
    node: ch6;
    outmsg: CH16;

BEGIN
    sclear(nul_msg);
    SCLEAR(NODE);
    Writeln('DECNET Connect Test.');
    Write('task? ');
    Readln(task);
    Strunc(task);
    Write('Node? ');
    Readln(node);
{    Strunc(node);}
    ALUN(1,'NS',0);
    ALUN(2,'NS',0);
    Writeln('Call NTCONB to build a connect block...');
    NTCONB(node,chr(0),Task,CONB,STAT);
    Writeln('done. STAT=',stat:-6,'.');
    If STAT = 1 THEN
       BEGIN
       Writeln('Call NTOPN to get a network LUN and start DECNET...');
       NTOPN(1,f1,1,1,IOSB);
       Writeln('done. IOSB[1]=',iosb.int[1]:-6,' IOSB[2]=',iosb.int[2]:-6);
       IF IOSB.int[1] = 1 THEN
	   BEGIN
	   Writeln('Call NTCON to connect (to <',
    		node,'::',task,'>)...');
	   NTCON(2,f2,nul_msg,CONB,inmsg,IOSB);
           Writeln('done. IOSB[1]=',iosb.int[1]:-6,' IOSB[2]=',iosb.int[2]:-6);
	   NTDRB(Conb);
{ note hack ...}
       	   if iosb.int[1] <> iosb.int[1] THEN
		BEGIN
		Writeln('Call NTSND to send 5 messages.');
		sassign(outmsg,'HI FROM TST1');
		N := 0;
	    	While (IOSB.int[1] = 1) AND (N < 5) DO 
		    BEGIN
		    NTSND(2,f2,loophole(address,ref(outmsg)),slen(outmsg),IOSB);
		    Writeln('done. IOSB[1]=',iosb.int[1]:-6,' IOSB[2]=',iosb.int[2]:-6);
		    N := N + 1
		    end
		end;
    	    Writeln('Waiting for link to clear....');
	    Wait(f3,5,seconds); { let things settle before disconnect...}

    	    Writeln('Call NTDSC to disconnect link...');
	    NTDSC(2,f2,nul_msg,IOSB);
	    Writeln('done. IOSB[1]=',iosb.int[1]:-6,' IOSB[2]=',iosb.int[2]:-6)
	   END
       END;
    Writeln('End of test.')
    end.	    
