Guest User

Untitled

a guest
Jan 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <sys/neutrino.h>
  3. #include <fcntl.h>
  4. #include <stdlib.h>
  5. #include <unistd.h>
  6.  
  7. int main()
  8. {
  9. int rcvid;
  10. int chid;
  11. int pid;
  12. int fd;
  13. char message [512];
  14. pid=getpid();
  15. chid=ChannelCreate(0);
  16.  
  17. printf("\nI am Server PID=%d . I create Channel %d\n",pid,chid);
  18. //fflush(stdout);
  19.  
  20. fd = open("server.msg", O_WRONLY|O_CREAT);
  21. if(fd==-1)printf("\nopen error = %d\n",fd);
  22. else printf("I was written my PID in file 'server.msg' Ok!\n");
  23. write (fd,&pid,sizeof(pid));
  24. close (fd);
  25.  
  26. while(1)
  27. { rcvid=MsgReceive(chid, message, sizeof(message), NULL);
  28. printf("Recive message, rcvid %x\n:", rcvid);
  29. printf("Message body: %s\n", message);
  30. strcpy(message, "This is answer");
  31. MsgReply(rcvid, 0, message, sizeof(message));
  32. }
  33. return(0) ;
  34. }
Add Comment
Please, Sign In to add comment