REM > FindServer REM Use FindServer protocol to find a server : DIM ctrl% 31:X%=ctrl%:Y%=X%DIV256 DIM rxBuf% 31,txBuf% 15:rx%=0:tx%=0 : ON ERROR REPORT:PROCNet_RxKill(rx%):PRINT:END : rx%=FNNet_RxOpen(0,&B1,rxBuf%,&20) $txBuf%="DESPOOL " :REM Look for a DESPOOL server $txBuf%="MUGINS " :REM Look for a MUGINS server $txBuf%="RISCOS " :REM Look for a RISCOS server $txBuf%="TELETEXT" :REM Look for a TELETEXT server $txBuf%="UNIX " :REM Look for a UNIX server $txBuf%=" " :REM Look for all server types try%=10 REPEAT tx%=FNNet_TxCount(&FFFF,&80,&B0,txBuf%,8,0,0,0) IF tx% THEN PRINT FNNet_Err(tx%):END rxok%=FNNet_Rx(rx%) IF NOT rxok%:A%=TIME+50:REPEATUNTILTIME>A%:try%=try%-1 UNTIL rxok% OR try%<1 IF NOT rxok% THEN PROCNet_RxKill(rx%):PRINT "No server found":END rxnum%=FNNet_RxRead(rx%):stn%=X%!3 PRINT "Server found on station ";FNNet_Stn(stn%) IF ?rxBuf% THEN PRINT "Server error: ";$(rxBuf%+1):END rxBuf%?(12+rxBuf%?11)=13:name$=$(rxBuf%+12) rxBuf%?11=13:server$=$(rxBuf%+3) vers%=rxBuf%?2 portBase%=rxBuf%?1 PRINT "Type: ";server$;" Name: ";name$ PRINT "Base port: &";FNh0(portBase%,2);" Version: ";vers%DIV16;".";(vers%AND15)*10 END : : : : : : DEFFNNet_TxCount(Stn%,Ctrl%,Port%,Addr%,Len%,RAddr%,Try%,Delay%):LOCAL TxErr% DEFFNNet_Tx(Stn%,Ctrl%,Port%,Addr%,Len%,RAddr%):LOCAL TxErr%,Try%,Delay%:Try%=10:Delay%=50 X%?1=Port%:X%!2=Stn%:X%!4=Addr%:X%!8=Addr%+Len%:X%!12=RAddr% IFStn%=&FFFF:X%!4=Addr%!0:X%!8=Addr%!4 REPEAT:REPEAT:X%?0=Ctrl%:A%=&10:CALL &FFF1:UNTILX%?0 REPEAT:TxErr%=FNbyte(&32,0,0):UNTILTxErr%<&80 IFTxErr%=&41 OR TxErr%=&42:IFTry%:A%=TIME+Delay%:REPEATUNTILTIME>A%:Try%=Try%-1 UNTILNOT(TxErr%=&41 OR TxErr%=&42) OR Try%<1:=TxErr% : DEFFNNet_RxOpen(Stn%,Port%,Addr%,Len%) X%?0=0:X%?1=&7F:X%?2=Port%:X%!3=Stn%:X%!5=Addr%:X%!9=Addr%+Len% A%=&11:CALL &FFF1:=X%?0 : DEFFNNet_Rx(RxNum%):=(FNbyte(&33,RxNum%,0)AND&80)<>0 : DEFFNNet_RxRead(RxNum%) X%?0=RxNum%:A%=&11:CALL &FFF1:A%=X%!9-X%!5:X%!5=0:=A% : DEFPROCNet_RxKill(RxNum%):A%=FNbyte(&34,RxNum%,0):ENDPROC : DEFFNNet_Err(A%):IFA%=0:="" =MID$("Line jammedNet errorNot listeningNo clockBad Tx blockNo reply",VALMID$("011221344254",(A%-&40)*2+1,2),VALMID$("110913081208",(A%-&40)*2+1,2)) : DEFFNNet_Stn(A%):=LEFT$(FNd0(A%DIV256,3)+".",(A%DIV256)<>0)+FNd0(A%AND255,3) DEFFNNet_StnFixed(A%):=FNd0(A%DIV256,3)+"."+FNd0(A%AND255,3) : DEFFNbyte(A%,X%,Y%)=((USR&FFF4)AND&FF00)DIV256 DEFFNd0(A%,N%)=RIGHT$("00000000"+STR$A%,N%) DEFFNh0(A%,N%)=RIGHT$("0000000"+STR$~A%,N%)