Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <stdio.h>
  3. #include <error.h>
  4. #include <sys/types.h>
  5. #include <sys/wait.h>
  6. #include <iostream>
  7. #include <cstring>
  8. #include <fstream>
  9. #include <sys/stat.h>
  10. #include <errno.h>
  11. #include <fcntl.h>
  12. #include <stdlib.h>
  13.  
  14. using namespace std;
  15. #define MAXLINE 128
  16.  
  17. #define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
  18. #define FIFO1 "fifo.1"
  19.  
  20. #define FIFO2 "fifo.2"
  21.  
  22. int main(int argi, char **arg2)
  23.  
  24. int readrt
  25. ) size_t n=
  26. char f_str[MAXLINE];
  27. char s_str[MAXLINE];
  28. cout<<"Server is on"<<endl;
  29. unlink(FIFO1);
  30. unlink (FIFO2) ;
  31.  
  32.  
  33.  
  34. -1, writert =
  35.  
  36.  
  37.  
  38.  
  39.  
  40. if (mkfifo(FIFO1, FILE_MODE)==EEXIST)cout<<"\n Pipes is exist"<<endl;
  41.  
  42. if (mkFifo(FIFO2, FILE_MODE.
  43. cout<<"Enter text:"<<endl;
  44.  
  45. writert = open(FIFO2, O_WRONLY);
  46. if ((writert!=-1))
  47.  
  48. while (1)
  49. {
  50.  
  51.  
  52.  
  53.  
  54.  
  55. cin>>f_str;
  56. write(writert, f_str,strlen(f_str));
  57. readrt = open(FIFO1, 0_RDONLY);
  58.  
  59. while ((n=read(readrt,s_str,MAXLINE))>0){
  60. s_str[n] =0;
  61.  
  62. cout<<s_str<<endl;
  63.  
  64. break;
  65.  
  66.  
  67.  
  68. }
  69. if (strcmp(f_str, "exitor|')==0) break;
  70.  
  71. EXIST)cout<<"\n Pipes is exist"<<endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement