public
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
 
#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);
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.