Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- #include "structs.h"
- #include "server.h"
- #include "client.h"
- int main(void)
- {
- pid_t pid;
- int mypipe[2];
- int otherPipe[2];
- if(pipe(mypipe))
- {
- printf("Error in making a pipe");
- }
- if(pipe(otherPipe))
- {
- printf("Error creating another pipe");
- }
- if((pid=fork()) == -1)
- {
- perror("fork");
- exit(1);
- }
- printf("Child ID: %d" , pid);
- if(pid == 0)
- {
- close(mypipe[1]);
- close(otherPipe[0]);
- client *c = new client(mypipe[0], otherPipe[1]);
- wait(NULL);
- //c->startProgram();
- //return EXIT_SUCCESS;
- }
- else
- {
- printf("Yo");
- close(mypipe[0]);
- close(otherPipe[1]);
- server s;
- s.fdIn = otherPipe[0];
- s.fdOut = mypipe[1];
- s.startServer();
- //wait(NULL);
- //return EXIT_SUCCESS;
- }
- }
Add Comment
Please, Sign In to add comment