Skip to content

Instantly share code, notes, and snippets.

@sustrik
Created November 17, 2011 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sustrik/1372839 to your computer and use it in GitHub Desktop.
Save sustrik/1372839 to your computer and use it in GitHub Desktop.
#include <sp.h>
#include <assert.h>
#include <stdio.h>
int main (int argc, char *argv[])
{
int sock, rc;
struct sockaddr_sp addr;
char buffer [1024];
ssize_t nbytes;
/* Create an SP socket. */
sock = socket (PF_SP, SOCK_SUB, 0);
assert (sock);
/* Connect it to the supplied endpoint */
memset (&addr, 0, sizeof addr);
addr.ssp_family = AF_SP;
strcpy (addr.ssp_endpoint, "tcp://127.0.0.1:1111");
rc = connect (sock, (struct sockaddr *)&addr, sizeof addr);
assert (rc == 0);
while (1) {
/* Receive a message */
nbytes = recv (sock, buffer, sizeof buffer, 0);
assert (nbytes >= 0);
/* Print the content as a string */
buffer [nbytes] = 0;
printf ("received <%s>\n", buffer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment