00001 /* 00002 SMI-based client 00003 AUP2, Sec. 7.03.2 00004 00005 Copyright 2003 by Marc J. Rochkind. All rights reserved. 00006 May be copied only for purposes and under conditions described 00007 on the Web page www.basepath.com/aup/copyright.htm. 00008 00009 The Example Files are provided "as is," without any warranty; 00010 without even the implied warranty of merchantability or fitness 00011 for a particular purpose. The author and his publisher are not 00012 responsible for any damages, direct or incidental, resulting 00013 from the use or non-use of these Example Files. 00014 00015 The Example Files may contain defects, and some contain deliberate 00016 coding mistakes that were included for educational reasons. 00017 You are responsible for determining if and how the Example Files 00018 are to be used. 00019 00020 */ 00021 #include "defs.h" 00022 #include "smsg_smi.h" 00023 00024 00025 /* Client */ 00026 00027 /*[main]*/ 00028 int main(int argc, char *argv[]) 00029 { 00030 SMIQ *sqp; 00031 struct smi_msg *msg; 00032 int i; 00033 00034 char *work[] = { 00035 "applesauce", 00036 "tiger", 00037 "mountain", 00038 NULL 00039 }; 00040 00041 printf("client %ld started\n", (long)getpid()); 00042 ec_null( sqp = smi_open(SERVER_NAME, SMI_CLIENT, DATA_SIZE) ) 00043 for (i = 0; work[i] != NULL; i++) { 00044 ec_false( smi_send_getaddr(sqp, NULL, (void **)&msg) ) 00045 strcpy(msg->smi_data, work[i]); 00046 ec_false( smi_send_release(sqp) ) 00047 ec_false( smi_receive_getaddr(sqp, (void **)&msg) ) 00048 printf("client %ld: %s --> %s\n", (long)getpid(), 00049 work[i], msg->smi_data); 00050 ec_false( smi_receive_release(sqp) ) 00051 } 00052 ec_false( smi_close(sqp) ) 00053 printf("Client %ld done\n", (long)getpid()); 00054 exit(EXIT_SUCCESS); 00055 00056 EC_CLEANUP_BGN 00057 exit(EXIT_FAILURE); 00058 EC_CLEANUP_END 00059 }