Advertisement
Aaaaa988

receiver

Dec 24th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <pthread.h>
  3. #include <unistd.h>
  4. #include <stdlib.h>
  5. #include <sys/types.h>
  6. #include <sys/stat.h>
  7. #include <fcntl.h>
  8. #include <sys/neutrino.h>
  9. #include <sys/syspage.h>
  10. #include <iostream>
  11.  
  12. using namespace std;
  13.  
  14. int child;
  15.  
  16. void* func(void*){
  17. char rmsg, msg = 's';
  18. int rcvid = MsgReceive(child, NULL, 0, 0);
  19.  
  20. printf("[Server]: received empty msg\n);
  21. MsgReply(rcvid, 0, Null, 0);
  22. }
  23.  
  24. int main() {
  25. int pid;
  26. int thread;
  27. child = ChannelCreate(0);
  28. pid = getpid();
  29. int fd = open("taskOne.txt", O_CREAT+O_RDWR, 0666);
  30. write(fd, &pid, 4);
  31. write(fd, &child, 4);
  32. printf("Server: pid = %d; child = %d\n", pid, child);
  33.  
  34. pthread_create(&thread, 0, func, NULL);
  35. usleep(1000);
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement