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
916 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 connect to database client through VPN using Global Protect GUI?

Only the GUI version of the GlobalProtect ...READ MORE

answered Feb 8, 2022 in Cyber Security & Ethical Hacking by Edureka
• 13,620 points
994 views
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,220 points
2,342 views
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
1,180 views
0 votes
2 answers

Install postgreSQL on Ubuntu

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

answered Nov 12, 2020 in Database by Prachi
• 140 points
1,269 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
844 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP