Guest User

Untitled

a guest
Jan 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <sys/neutrino.h>
  3. #include <fcntl.h>
  4. #include <unistd.h>
  5. char *smsg="This is buffer";
  6. char rmsg[200];
  7. int coid;
  8.  
  9. int main()
  10. {
  11. int pid_client;
  12. int fd;
  13. int pid_ser;
  14. char* filename="server.msg";
  15. pid_client=getpid();
  16. printf("\nI am Client %d .",pid_client);
  17. printf("Testing of message exchanging\n");
  18.  
  19. fd=open(filename,O_RDONLY);
  20. if (fd==-1) printf("\nopen file %s error %d",filename,fd);
  21. else printf("file %s opennig Ok!",filename);
  22. read(fd,&pid_ser,sizeof(pid_ser));
  23. close(fd);
  24.  
  25. printf("\nPID servera %d .",pid_ser);
  26. fflush(stdout);
  27.  
  28. coid=ConnectAttach(0,pid_ser,1,0,0);
  29. if (coid==-1) {printf("Connection error\n");exit(1);}
  30. if (MsgSend(coid,smsg,strlen(smsg)+1,rmsg,sizeof(rmsg))==-1)
  31. {printf("Send message error\n");exit(1);}
  32. if (strlen(rmsg)>0) {printf("Process return %s\n",rmsg);}
  33. return(0);
  34. }
Add Comment
Please, Sign In to add comment