Created
November 17, 2011 10:09
-
-
Save sustrik/1372839 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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