Client Server Communication using Pipes

0 votes
I'm studying Operating System and this code has been written but i'm having difficulty figuring out what each of these snippets do?

What would be the Outputs of each of the following code snippets and why?

1. if ((mknod (FIFO1, S_IFIFO | PERMS, 0) < 0) && (errno != EEXIST))

 {

 perror ("mknod FIFO1");

 exit (1);

 }

2. if (mkfifo(FIFO2, PERMS) < 0)

{

 unlink (FIFO1);

 perror("mknod FIFO2");

 exit (1);

}

3. if ((readfd = open(FIFO1, 0)) < 0)

 {

 perror ("open FIFO1");

 exit (1);

}

4. if ((writefd = open(FIFO2, 1)) < 0)

{

 perror ("open FIFO2");

 exit (1);

}

5. size = strlen(MESSAGE1) + 1;

 if ((n = read(readfd, buff, size)) < 0) {

 perror ("server read"); exit (1);

 }

6. size = strlen(MESSAGE1) + 1;

 if (write(writefd, MESSAGE1, size) != size)

{

perror ("client write1"); exit (1);

}
Dec 16, 2020 in Cyber Security & Ethical Hacking by Edureka
• 120 points
122 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Cyber Security & Ethical Hacking

0 votes
1 answer
0 votes
1 answer

How to find MAC address using IP address?

To find the MAC address, run this ...READ MORE

answered Feb 9, 2019 in Cyber Security & Ethical Hacking by Omkar
• 69,090 points
566 views
0 votes
1 answer
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
263 views
0 votes
2 answers

Install postgreSQL on Ubuntu

Follow the below commands to install PostgreSQL (PSQL) ...READ MORE

answered Nov 11, 2020 in Database by Prachi
• 140 points
239 views
0 votes
1 answer

Access progrs prompt without switching accounts

Use the following to get the postgres prompt ...READ MORE

answered Mar 22, 2019 in Database by Mahi
164 views