This is a basic client API example, demonstrating how to handle streaming and non-streaming calls.
To run with the default URI: ./build/examples/client/example-client To specify the URI: ./build/examples/client/example-client unix://test2.sock Note that the unix domain socket example requires that client and server be run from the same directory specifying the same socket.
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <unistd.h>
#include <glib.h>
#include <errno.h>
#include <string.h>
int
main(int argc, const char *argv[])
{
const char *buf;
int64_t len;
int64_t num;
int cnt = 0;
if (argc > 1)
else
if (client == NULL) {
fprintf(stderr, "cannot connect: %s\n",
return (1);
}
fprintf(stderr, "Remote pid is %d\n",
}
if (call == NULL) {
fprintf(stderr, "Stream call failed\n");
return (1);
}
for (;;) {
break;
&buf, &len, &num);
cnt++;
fprintf(stderr,
"frag = %s, len = %" PRId64 ", num = %" PRId64 ","
"cnt = %d\n", buf, len, num, cnt);
g_assert(len == (int)strlen(buf));
break;
fprintf(stderr, "ENDED at %d\n", cnt);
goto done;
fprintf(stderr, "ERRORED out\n");
goto done;
fprintf(stderr, "ABORTED at %d\n", cnt);
goto done;
default:
break;
}
}
done:
fprintf(stderr, "CLOSING client conn %p, cnt = %d\n", conn, cnt);
return (0);
}