Commit 44385919 authored by Philip Carns's avatar Philip Carns

fill in example calling multiple mplex'd services

parent a5ebf0d5
......@@ -7,4 +7,5 @@ examples_multiplex_margo_example_mp_server_SOURCES = \
examples_multiplex_margo_example_mp_client_SOURCES = \
examples/multiplex/margo-example-mp-client.c \
examples/multiplex/svc1-client.c
examples/multiplex/svc1-client.c \
examples/multiplex/svc2-client.c
......@@ -12,6 +12,7 @@
#include <margo.h>
#include "svc1-client.h"
#include "svc2-client.h"
static hg_id_t my_rpc_shutdown_id;
......@@ -80,12 +81,18 @@ int main(int argc, char **argv)
NULL);
/* register service APIs */
svc1_register_client(mid);
svc2_register_client(mid);
/* find addr for server */
ret = margo_addr_lookup(mid, argv[1], &svr_addr);
assert(ret == 0);
svc1_do_thing(mid, svr_addr, 1);
svc1_do_other_thing(mid, svr_addr, 1);
svc1_do_thing(mid, svr_addr, 2);
svc1_do_other_thing(mid, svr_addr, 2);
svc2_do_thing(mid, svr_addr, 3);
svc2_do_other_thing(mid, svr_addr, 3);
/* send one rpc to server to shut it down */
/* create handle */
......
......@@ -78,3 +78,51 @@ void svc1_do_thing(margo_instance_id mid, hg_addr_t svr_addr, uint32_t mplex_id)
return;
}
void svc1_do_other_thing(margo_instance_id mid, hg_addr_t svr_addr, uint32_t mplex_id)
{
hg_handle_t handle;
svc1_do_other_thing_in_t in;
svc1_do_other_thing_out_t out;
int ret;
hg_size_t size;
void* buffer;
struct hg_info *hgi;
/* allocate buffer for bulk transfer */
size = 512;
buffer = calloc(1, 512);
assert(buffer);
sprintf((char*)buffer, "Hello world!\n");
/* create handle */
ret = HG_Create(margo_get_context(mid), svr_addr, svc1_do_other_thing_id, &handle);
assert(ret == 0);
/* register buffer for rdma/bulk access by server */
hgi = HG_Get_info(handle);
assert(hgi);
ret = HG_Bulk_create(hgi->hg_class, 1, &buffer, &size,
HG_BULK_READ_ONLY, &in.bulk_handle);
assert(ret == 0);
hgi->mplex_id = mplex_id;
/* Send rpc. Note that we are also transmitting the bulk handle in the
* input struct. It was set above.
*/
in.input_val = 0;
margo_forward(mid, handle, &in);
/* decode response */
ret = HG_Get_output(handle, &out);
assert(ret == 0);
/* clean up resources consumed by this rpc */
HG_Bulk_free(in.bulk_handle);
HG_Free_output(handle, &out);
HG_Destroy(handle);
free(buffer);
return;
}
......@@ -12,5 +12,6 @@
int svc1_register_client(margo_instance_id mid);
void svc1_do_thing(margo_instance_id mid, hg_addr_t svr_addr, uint32_t mplex_id);
void svc1_do_other_thing(margo_instance_id mid, hg_addr_t svr_addr, uint32_t mplex_id);
#endif /* __SVC1_CLIENT */
......@@ -9,4 +9,9 @@
#include <margo.h>
int svc2_register_client(margo_instance_id mid);
void svc2_do_thing(margo_instance_id mid, hg_addr_t svr_addr, uint32_t mplex_id);
void svc2_do_other_thing(margo_instance_id mid, hg_addr_t svr_addr, uint32_t mplex_id);
#endif /* __SVC2_CLIENT */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment