Tag Only for the Citect Server and its Local Client

Hi,

Can we in Citect (ver 2018 R2->) create an tag that is "1" only on the server and for the local server client? Meaning any Remote Clients running outside the actual server hardware will read this tag as "0". 

Indicates if the server the application is running on is the server or a client. 

This can be used to start/stop/control local 3'rd party programs running on the server hardware and can only be operated/used directly on this hardware. 

Thanks,

Rune

Parents
  • Not sure if you still need this, but here's a Cicode function that returns 1 if called from any process on a server computer, and returns 0 on a client. I had used it to look up the network address name of the local server, so it was just a minor change to just return true/false. 

    INT mbComputerIsServer = -1;
    
    //Returns TRUE if this computer runs any server processes, otherwise FALSE
    //The calling process does not have to be a server process
    STRING FUNCTION ComputerIsServer()
    	INT		cRpcBlocking = 0;
    	INT		hServers;
    	STRING	sLocalComputer;
    	STRING	sServerComputer;
    	STRING	sServer;
    	STRING	sType;
    	STRING	sCluster;
    
    	ErrSet(1);
    	
    	IF mbComputerIsServer = -1 THEN
    		mbComputerIsServer = FALSE;
    		sLocalComputer = GetEnv("ComputerName");
    	
    		hServers = ServerBrowseOpen("", "NAME,TYPE,NETADDR,CLUSTER");
    		ServerBrowseFirst(hServers);
    		sServer = ServerBrowseGetField(hServers, "NAME");
    		
    		WHILE (sServer <> "") AND (mbComputerIsServer = FALSE) DO
    			sType = ServerBrowseGetField(hServers, "TYPE");
    			IF sType = "I/O" THEN
    				sType = "IOServer";	//Different abbreviation used for ProcessIsServer()
    			END
    			
    			sCluster = ServerBrowseGetField(hServers, "CLUSTER");
    			
    			sServerComputer = ServerRPC(sServer, "GetEnv", "^"ComputerName^"", cRpcBlocking, sCluster);
    			
    			IF sLocalComputer = sServerComputer THEN
    				mbComputerIsServer = TRUE;
    			END
    	
    			ServerBrowseNext(hServers);
    			sServer = ServerBrowseGetField(hServers, "NAME");
    		END
    		
    		ServerBrowseClose(hServers);
    	END
    	
    	RETURN mbComputerIsServer;
    END	
    
Reply
  • Not sure if you still need this, but here's a Cicode function that returns 1 if called from any process on a server computer, and returns 0 on a client. I had used it to look up the network address name of the local server, so it was just a minor change to just return true/false. 

    INT mbComputerIsServer = -1;
    
    //Returns TRUE if this computer runs any server processes, otherwise FALSE
    //The calling process does not have to be a server process
    STRING FUNCTION ComputerIsServer()
    	INT		cRpcBlocking = 0;
    	INT		hServers;
    	STRING	sLocalComputer;
    	STRING	sServerComputer;
    	STRING	sServer;
    	STRING	sType;
    	STRING	sCluster;
    
    	ErrSet(1);
    	
    	IF mbComputerIsServer = -1 THEN
    		mbComputerIsServer = FALSE;
    		sLocalComputer = GetEnv("ComputerName");
    	
    		hServers = ServerBrowseOpen("", "NAME,TYPE,NETADDR,CLUSTER");
    		ServerBrowseFirst(hServers);
    		sServer = ServerBrowseGetField(hServers, "NAME");
    		
    		WHILE (sServer <> "") AND (mbComputerIsServer = FALSE) DO
    			sType = ServerBrowseGetField(hServers, "TYPE");
    			IF sType = "I/O" THEN
    				sType = "IOServer";	//Different abbreviation used for ProcessIsServer()
    			END
    			
    			sCluster = ServerBrowseGetField(hServers, "CLUSTER");
    			
    			sServerComputer = ServerRPC(sServer, "GetEnv", "^"ComputerName^"", cRpcBlocking, sCluster);
    			
    			IF sLocalComputer = sServerComputer THEN
    				mbComputerIsServer = TRUE;
    			END
    	
    			ServerBrowseNext(hServers);
    			sServer = ServerBrowseGetField(hServers, "NAME");
    		END
    		
    		ServerBrowseClose(hServers);
    	END
    	
    	RETURN mbComputerIsServer;
    END	
    
Children
No Data