Skip to content

Instantly share code, notes, and snippets.

@wormyrocks
Created July 29, 2019 16:18
Show Gist options
  • Save wormyrocks/c23ca05cbe6e79e969c068c54fb27ebd to your computer and use it in GitHub Desktop.
Save wormyrocks/c23ca05cbe6e79e969c068c54fb27ebd to your computer and use it in GitHub Desktop.
char addressBuffer[INET_ADDRSTRLEN];
getip(addressBuffer);
char url1[100];
sprintf(url1, "ws://%s:11222/driver", addressBuffer);
char *url2 = "ipc:///tmp/pipe.ipc";
int rv;
printf("Beginning repeater %s -> %s...\n", url1, url2);
if ((rv = nng_rep0_open_raw(&sock1)) != 0)
fatal("nng_socket", rv);
if ((rv = nng_rep0_open_raw(&sock1)) != 0)
fatal("nng_rep0_open_raw", rv);
if ((rv = nng_req0_open_raw(&sock2)) != 0)
fatal("nng_req0_open_raw", rv);
if ((rv = nng_setopt_size(sock1, NNG_OPT_RECVMAXSZ, 0)) != 0)
fatal("nng_setopt_size", rv);
if ((rv = nng_setopt_size(sock2, NNG_OPT_RECVMAXSZ, 0)) != 0)
fatal("nng_setopt_size", rv);
if ((rv = nng_listen(sock1, url1, NULL, 0)) != 0)
fatal("nng_listen", rv);
if ((rv = nng_dial(sock2, url2, NULL, 0)) != 0)
fatal("nng_dial", rv);
printf("Repeater started successfully.\n");
if ((rv = nng_device(sock1, sock2)) != 0)
fatal("nng_device", rv);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment