RPC.CONNECT function

Syntax

RPC.CONNECT (host, server)

Description

Use the RPC.CONNECT function to establish a connection to a server process. Once the host and server are identified, the local daemon tries to connect to the remote server. If the attempt succeeds, RPC.CONNECT returns a connection ID. If it fails, RPC.CONNECT returns 0. The connection ID is a nonzero integer used to refer to the server in subsequent calls to RPC.CALL function and RPC.DISCONNECT function.

host is the name of the host where the server resides.

UNIX. This is defined in the local /etc/hosts file.

Windows. This is defined in the system32\drivers\etc\hosts file.

server is the name, as defined in the remote /etc/services file, of the RPC server class on the target host.

If host is not in the /etc/hosts file, or if server is not in the remote /etc/services file, the connection attempt fails.

Use the STATUS function after an RPC.CONNECT function is executed to determine the result of the operation, as follows:

81005
Connection failed because of a mismatch of RPC versions.
81007
Connection refused because the server cannot accept more clients.
81009
Unspecified RPC error.
81011
Host is not in the local /etc/hosts file.
81012
Remote dsrpcd cannot start service because it could not fork the process.
81013
Cannot open the remote dsrpcservices file.
81014
Service not found in the remote dsrpcservices file.
81015
Connection attempt timed out.

Example

The following example connects to a remote server called MONITOR on HOST.A:

MAT args(1,2), res(1,2)
server.handle = RPC.CONNECT ("HOST.A", "MONITOR")
IF (server.handle = 0) THEN
   PRINT "Connection failed, error code is: ": 
STATUS()
   STOP
END