Listing 2. Receiver code snip
// Receiver code snip
char replyArea[2048];
main(int argc, char **argv)
{
int fromWhom;
int nbytes;
char *msg;
// give the receiver a SIMPL name
attachName(MYRECEIVER, 2048, NULL);
// block waiting for a message
fromWhom = receiveMsg(&msg, &nbytes);
// display the incoming message
printf("rec'd %d byte message=<%s<\n", nbytes, msg);
// build the reply message
sprintf(replyArea, "the world says hello");
// post the reply
loadReply(fromWhom,replyArea,strlen(replyArea));
replyMsg(fromWhom);
// cleanup
detachName();
} // end receiver
Copyright © 1994 - 2018 Linux Journal. All rights reserved.