Attaching to Remote Contexts in HPC++

Attaching to a remote context means connecting to an already existing context and getting its context ID. In HPC++, this is accomplished through the call hpcxx_grabContext:

HPCxx_ContextID serverCID;
char *serverHost = "";
int serverPort = 12345;

hpcxx_grabContext(&serverCID, serverHost, serverPort);
The above call attaches to a remote context running on and listening for connections on port 12345. The server's context ID is returned through the first parameter. This same call works for both Globus and Nexus based HPC++.

In order for clients to attach to it, the server context itself needs to call an HPC++ function declaring its willingness to be attached:

hpcxx_allowAttach(12345, callback-function, callback-function-arg);
By calling this function, the server context allows other contexts to attach to it on port 12345. The second parameter is a callback function that will get called when a client makes an attach request on the server. This is an upcall from the run-time system to the server provided function. The third parameter is the argument with which this function will be called. Typically, the server context is not interested in getting a callback on attach request, and hence both of these parameters can be set to be NULL.

The online tutorial examples section contains a detailed example illustrating remote context attachment.

Last modified: Wed Apr 21 22:47:22 EST 1999