Guest User

Untitled

a guest
Jan 22nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <sys/types.h>
  5. #include <sys/wait.h>
  6.  
  7. #include "structs.h"
  8. #include "server.h"
  9. #include "client.h"
  10.  
  11.  
  12. int main(void)
  13. {
  14.  
  15. pid_t pid;
  16. int mypipe[2];
  17. int otherPipe[2];
  18.  
  19. if(pipe(mypipe))
  20. {
  21. printf("Error in making a pipe");
  22. }
  23. if(pipe(otherPipe))
  24. {
  25. printf("Error creating another pipe");
  26. }
  27. if((pid=fork()) == -1)
  28. {
  29. perror("fork");
  30. exit(1);
  31. }
  32. printf("Child ID: %d" , pid);
  33. if(pid == 0)
  34. {
  35. close(mypipe[1]);
  36. close(otherPipe[0]);
  37. client *c = new client(mypipe[0], otherPipe[1]);
  38. wait(NULL);
  39. //c->startProgram();
  40. //return EXIT_SUCCESS;
  41. }
  42. else
  43. {
  44. printf("Yo");
  45. close(mypipe[0]);
  46. close(otherPipe[1]);
  47. server s;
  48. s.fdIn = otherPipe[0];
  49. s.fdOut = mypipe[1];
  50. s.startServer();
  51. //wait(NULL);
  52. //return EXIT_SUCCESS;
  53. }
  54. }
Add Comment
Please, Sign In to add comment