PreviousNext

Binding Explicitly to Known Objects

To bind to an object explicitly by its binding handle, the argument provided to the bind( ) operation should be a server binding handle of type rpc_binding_handle_t. Note that this method does not use CDS at all. For example, the following code fragment uses a binding handle to create a local object proxy in the client application bound to a remote object.

const char *UUID = "f063cf5a-c5c8-11ce-8a4b-08002be415b2";
const char *PROT = "ncacn_ip_tcp";
const char *HOST = "16.01.02.03";
const char *ENDP = "4041";

Matrix *m; // interface pointer
unsigned_char_t *string_binding; // string binding
rpc_binding_handle_t binding_handle; // binding
handle unsigned32 status; // error status

// build a string binding from the various components
rpc_string_binding_compose(
(unsigned_char_t *) UUID, // object uuid
(unsigned_char_t *) PROT, // protocol sequence
(unsigned_char_t *) HOST, // host address
(unsigned_char_t *) ENDP, // transport endpoint
NULL, // network options
&string_binding,
&status
);
if (status != rpc_s_ok) {
// handle error case
}
// convert a string binding into a binding handle
rpc_binding_from_string_binding(
string_binding,
&binding_handle,
&status );
if (status != rpc_s_ok)
{
// handle error case
}
m = Matrix::bind(binding_handle);
if (m) {
print(m);
} else {
cerr << "Cannot bind to named object" << endl;
}

rpc_string_binding_compose( )
This RPC API routine combines string components of binding information into a single string representation of a binding.

rpc_binding_from_string_binding( )
This RPC API routine creates a binding handle from a string representation of a binding handle.

m= Matrix::bind(binding_handle);
The bind( ) operation when used with a binding handle parameter binds to the object specified by the object's UUID and specific server binding information.