Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#ifndef CRYPT _ H #define CRYPT _ H #define MAX _ BUFF 1 0 2 4 #define STDIN 0 #define STDOUT 1 #define STDERR 2

#ifndef CRYPT_H
#define CRYPT_H
#define MAX_BUFF 1024
#define STDIN 0
#define STDOUT 1
#define STDERR 2
void client(int readfd /*read head of channel */, int writefd /*write head of channel */);
void server(int readfd /*read head of channel */, int writefd /*write head of channel */);
double calculate(char *buf);
#endif
#include
#include
#include
#include
#include
#include
#include
int main(int argc, char **argv){
/*************************************************************
write code for the main process that will establish
the communication channel between cleint and server using
pipes
*************************************************************/
pid_t pid;
// TODO:
int fd[2];
int pipe(int pipefd[2]);
if(pipe(fd)=0){
printf("Hello"
);
exit(-1);
}
pid = fork();
if(pid <0){
perror("Fork failed
");
return 1;
}
if(pid ==0){
// TODO:
//call to server here: server(int readfd, int writefd);
exit(0);
}
// TODO:
//call to client here client(int readfd, int writefd);
return 0;
}
#include
#include
#include
#include
#include
#include
#include
void client(int readfd, int writefd){
/*************************************************************
write client code to be used by the parent process
*************************************************************/
char buf[MAX_BUFF];
size_t len;
// implement client functionality
}
#include
#include
#include
#include
#include
#include
#include
void server(int readfd, int writefd){
/*************************************************************
write server code to be used by the child process
*************************************************************/
char buf[MAX_BUFF];
size_t len;
/* Implement server functionlity here
use calculate function to evaluate expression
signature: calculate(char *buf)
*/
}
#include
#include
#include
#include
#include
#include
#include
double calculate(char *buf){
/*************************************************************
Implement the expression evaluation functionality which
will be invoked by the server whenever required.
*************************************************************/
double operands[20];
char op[20];
int oprnInd =0;
double result =0.0;
// implement expression evaluation functionality here
return(result);
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago