SlideShare a Scribd company logo
1 of 5
Download to read offline
Hello,
Ther is some problem in you code
I made my own programme as per your requirement
Please check my solution :-
1)Create one FIFO
2)From Client write character first and wait for some time so that server will read it
3) After wait for some time write integer
Server programme :-
---------------------------------------
#include
#include
#include
#include
#include
int main()
{
int client_to_server;
char *myfifo = "/tmp/client_to_server_fifo";
char str;
int iteration;
/* create the FIFO (named pipe) */
mkfifo(myfifo, 0666);
/* open, read, and display the message from the FIFO */
client_to_server = open(myfifo, O_RDONLY);
printf("Server ON. ");
read(client_to_server, &str, sizeof(str));
read(client_to_server, &iteration, sizeof(iteration));
close(client_to_server);
unlink(myfifo);
//Now Print the character
for(int i = 0; i < iteration ; i++){
printf("Iteration ::%d and Character:: %c ",i,str);
}
return 0;
}
Client Programme :-
---------------------------------------
#include
#include
#include
#include
#include
int main()
{
int client_to_server;
char *myfifo = "/tmp/client_to_server_fifo";
char str;
int iteration;
printf("Client: Please enter a character: ");
scanf("%c", &str);
printf("Client: Please enter an integer: ");
scanf("%d", &iteration);
/* write str to the FIFO */
client_to_server = open(myfifo, O_WRONLY);
//First write character
write(client_to_server, &str, sizeof(str));
//wait for some time so that server will read character
sleep(0.250);
//Then write integer
write(client_to_server, &iteration, sizeof(iteration));
perror("Write:"); //Very crude error check
printf("...received from the server: %s ",str);
close(client_to_server);
/* remove the FIFO */
return 0;
}
Solution
Hello,
Ther is some problem in you code
I made my own programme as per your requirement
Please check my solution :-
1)Create one FIFO
2)From Client write character first and wait for some time so that server will read it
3) After wait for some time write integer
Server programme :-
---------------------------------------
#include
#include
#include
#include
#include
int main()
{
int client_to_server;
char *myfifo = "/tmp/client_to_server_fifo";
char str;
int iteration;
/* create the FIFO (named pipe) */
mkfifo(myfifo, 0666);
/* open, read, and display the message from the FIFO */
client_to_server = open(myfifo, O_RDONLY);
printf("Server ON. ");
read(client_to_server, &str, sizeof(str));
read(client_to_server, &iteration, sizeof(iteration));
close(client_to_server);
unlink(myfifo);
//Now Print the character
for(int i = 0; i < iteration ; i++){
printf("Iteration ::%d and Character:: %c ",i,str);
}
return 0;
}
Client Programme :-
---------------------------------------
#include
#include
#include
#include
#include
int main()
{
int client_to_server;
char *myfifo = "/tmp/client_to_server_fifo";
char str;
int iteration;
printf("Client: Please enter a character: ");
scanf("%c", &str);
printf("Client: Please enter an integer: ");
scanf("%d", &iteration);
/* write str to the FIFO */
client_to_server = open(myfifo, O_WRONLY);
//First write character
write(client_to_server, &str, sizeof(str));
//wait for some time so that server will read character
sleep(0.250);
//Then write integer
write(client_to_server, &iteration, sizeof(iteration));
perror("Write:"); //Very crude error check
printf("...received from the server: %s ",str);
close(client_to_server);
/* remove the FIFO */
return 0;
}

More Related Content

Similar to Hello,Ther is some problem in you codeI made my own programme as.pdf

E yantra robot abstractions
E yantra robot abstractionsE yantra robot abstractions
E yantra robot abstractions
Akshar Desai
 
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP  #inc.pdfCODE FOR echo_client.c A simple echo client using TCP  #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
secunderbadtirumalgi
 
VoIP - Cisco CME &amp; IP Communicator
VoIP - Cisco CME &amp; IP CommunicatorVoIP - Cisco CME &amp; IP Communicator
VoIP - Cisco CME &amp; IP Communicator
chinmaypadhye1985
 
Router and switch basics configuration
Router and switch basics configurationRouter and switch basics configuration
Router and switch basics configuration
Missangae
 
Write and set up signal handlers for each of the following signals S.pdf
 Write and set up signal handlers for each of the following signals S.pdf Write and set up signal handlers for each of the following signals S.pdf
Write and set up signal handlers for each of the following signals S.pdf
ssuser8308881
 

Similar to Hello,Ther is some problem in you codeI made my own programme as.pdf (20)

FIFOPt
FIFOPtFIFOPt
FIFOPt
 
Fortran compiling 2
Fortran compiling 2Fortran compiling 2
Fortran compiling 2
 
Finding 0days at Arab Security Conference
Finding 0days at Arab Security ConferenceFinding 0days at Arab Security Conference
Finding 0days at Arab Security Conference
 
E yantra robot abstractions
E yantra robot abstractionsE yantra robot abstractions
E yantra robot abstractions
 
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP  #inc.pdfCODE FOR echo_client.c A simple echo client using TCP  #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
 
Reverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentalsReverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentals
 
#1 How to develop a VoIP softphone in C# by using Ozeki VoIP SIP SDK - Part 1
#1 How to develop a VoIP softphone in C# by using Ozeki VoIP SIP SDK - Part 1#1 How to develop a VoIP softphone in C# by using Ozeki VoIP SIP SDK - Part 1
#1 How to develop a VoIP softphone in C# by using Ozeki VoIP SIP SDK - Part 1
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
 
Lecture9
Lecture9Lecture9
Lecture9
 
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
 
3.1.c apend scripting, crond, atd
3.1.c apend   scripting, crond, atd3.1.c apend   scripting, crond, atd
3.1.c apend scripting, crond, atd
 
Lab
LabLab
Lab
 
FMS Administration Seminar
FMS Administration SeminarFMS Administration Seminar
FMS Administration Seminar
 
VoIP - Cisco CME &amp; IP Communicator
VoIP - Cisco CME &amp; IP CommunicatorVoIP - Cisco CME &amp; IP Communicator
VoIP - Cisco CME &amp; IP Communicator
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
Introduction of Pharo 5.0
Introduction of Pharo 5.0Introduction of Pharo 5.0
Introduction of Pharo 5.0
 
Router and switch basics configuration
Router and switch basics configurationRouter and switch basics configuration
Router and switch basics configuration
 
Dive into exploit development
Dive into exploit developmentDive into exploit development
Dive into exploit development
 
101 apend. scripting, crond, atd
101 apend. scripting, crond, atd101 apend. scripting, crond, atd
101 apend. scripting, crond, atd
 
Write and set up signal handlers for each of the following signals S.pdf
 Write and set up signal handlers for each of the following signals S.pdf Write and set up signal handlers for each of the following signals S.pdf
Write and set up signal handlers for each of the following signals S.pdf
 

More from aradhana9856

Interest.javaimport java.util.Scanner; public class Interest.pdf
 Interest.javaimport java.util.Scanner; public class Interest.pdf Interest.javaimport java.util.Scanner; public class Interest.pdf
Interest.javaimport java.util.Scanner; public class Interest.pdf
aradhana9856
 
1) The Arrhenius Theory of acids and bases Acids are substances wh.pdf
  1) The Arrhenius Theory of acids and bases  Acids are substances wh.pdf  1) The Arrhenius Theory of acids and bases  Acids are substances wh.pdf
1) The Arrhenius Theory of acids and bases Acids are substances wh.pdf
aradhana9856
 
(i) Deques cannot be implemented using arrays. false    Justif.pdf
(i) Deques cannot be implemented using arrays.  false    Justif.pdf(i) Deques cannot be implemented using arrays.  false    Justif.pdf
(i) Deques cannot be implemented using arrays. false    Justif.pdf
aradhana9856
 
We all know humans are good at removing the competition and it is di.pdf
We all know humans are good at removing the competition and it is di.pdfWe all know humans are good at removing the competition and it is di.pdf
We all know humans are good at removing the competition and it is di.pdf
aradhana9856
 
Theories devised by keynes and Minsky are similar in concept since M.pdf
Theories devised by keynes and Minsky are similar in concept since M.pdfTheories devised by keynes and Minsky are similar in concept since M.pdf
Theories devised by keynes and Minsky are similar in concept since M.pdf
aradhana9856
 
Terry And Hill can develop a method of profit sharing on below facto.pdf
Terry And Hill can develop a method of profit sharing on below facto.pdfTerry And Hill can develop a method of profit sharing on below facto.pdf
Terry And Hill can develop a method of profit sharing on below facto.pdf
aradhana9856
 
The algorithm to reverse a linked list by rearranging the required p.pdf
The algorithm to reverse a linked list by rearranging the required p.pdfThe algorithm to reverse a linked list by rearranging the required p.pdf
The algorithm to reverse a linked list by rearranging the required p.pdf
aradhana9856
 
Splicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdf
Splicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdfSplicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdf
Splicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdf
aradhana9856
 

More from aradhana9856 (20)

First lets draw out the Lewis structure such that each atom has.pdf
 First lets draw out the Lewis structure such that each atom has.pdf First lets draw out the Lewis structure such that each atom has.pdf
First lets draw out the Lewis structure such that each atom has.pdf
 
Interest.javaimport java.util.Scanner; public class Interest.pdf
 Interest.javaimport java.util.Scanner; public class Interest.pdf Interest.javaimport java.util.Scanner; public class Interest.pdf
Interest.javaimport java.util.Scanner; public class Interest.pdf
 
13. The answer is C. 34Let D be the dominant allele and d be the.pdf
13. The answer is C. 34Let D be the dominant allele and d be the.pdf13. The answer is C. 34Let D be the dominant allele and d be the.pdf
13. The answer is C. 34Let D be the dominant allele and d be the.pdf
 
1) The Arrhenius Theory of acids and bases Acids are substances wh.pdf
  1) The Arrhenius Theory of acids and bases  Acids are substances wh.pdf  1) The Arrhenius Theory of acids and bases  Acids are substances wh.pdf
1) The Arrhenius Theory of acids and bases Acids are substances wh.pdf
 
1. Coenzyme A - C. A water soluble acyl group carrier.2. Thiamine .pdf
1. Coenzyme A - C. A water soluble acyl group carrier.2. Thiamine .pdf1. Coenzyme A - C. A water soluble acyl group carrier.2. Thiamine .pdf
1. Coenzyme A - C. A water soluble acyl group carrier.2. Thiamine .pdf
 
Using Clausius-Clapeyron relation Ln(P2P1) = (D.pdf
                     Using Clausius-Clapeyron relation Ln(P2P1) = (D.pdf                     Using Clausius-Clapeyron relation Ln(P2P1) = (D.pdf
Using Clausius-Clapeyron relation Ln(P2P1) = (D.pdf
 
purines are double ringed nitrogenous bases of DN.pdf
                     purines are double ringed nitrogenous bases of DN.pdf                     purines are double ringed nitrogenous bases of DN.pdf
purines are double ringed nitrogenous bases of DN.pdf
 
(i) Deques cannot be implemented using arrays. false    Justif.pdf
(i) Deques cannot be implemented using arrays.  false    Justif.pdf(i) Deques cannot be implemented using arrays.  false    Justif.pdf
(i) Deques cannot be implemented using arrays. false    Justif.pdf
 
no reaction note 1-butanol is a primary alcohol.pdf
                     no reaction  note 1-butanol is a primary alcohol.pdf                     no reaction  note 1-butanol is a primary alcohol.pdf
no reaction note 1-butanol is a primary alcohol.pdf
 
What type of variable is number of people in the roomNominal.pdf
What type of variable is number of people in the roomNominal.pdfWhat type of variable is number of people in the roomNominal.pdf
What type of variable is number of people in the roomNominal.pdf
 
What is the oxidation number for oxygen in H2O2; for OF2 Explain..pdf
What is the oxidation number for oxygen in H2O2; for OF2  Explain..pdfWhat is the oxidation number for oxygen in H2O2; for OF2  Explain..pdf
What is the oxidation number for oxygen in H2O2; for OF2 Explain..pdf
 
We all know humans are good at removing the competition and it is di.pdf
We all know humans are good at removing the competition and it is di.pdfWe all know humans are good at removing the competition and it is di.pdf
We all know humans are good at removing the competition and it is di.pdf
 
Theories devised by keynes and Minsky are similar in concept since M.pdf
Theories devised by keynes and Minsky are similar in concept since M.pdfTheories devised by keynes and Minsky are similar in concept since M.pdf
Theories devised by keynes and Minsky are similar in concept since M.pdf
 
They might have consumed cyanide.The pit of Apricot contains cyani.pdf
They might have consumed cyanide.The pit of Apricot contains cyani.pdfThey might have consumed cyanide.The pit of Apricot contains cyani.pdf
They might have consumed cyanide.The pit of Apricot contains cyani.pdf
 
The attacking of the nucleophile formed in the reactionof acetone an.pdf
The attacking of the nucleophile formed in the reactionof acetone an.pdfThe attacking of the nucleophile formed in the reactionof acetone an.pdf
The attacking of the nucleophile formed in the reactionof acetone an.pdf
 
Terry And Hill can develop a method of profit sharing on below facto.pdf
Terry And Hill can develop a method of profit sharing on below facto.pdfTerry And Hill can develop a method of profit sharing on below facto.pdf
Terry And Hill can develop a method of profit sharing on below facto.pdf
 
The algorithm to reverse a linked list by rearranging the required p.pdf
The algorithm to reverse a linked list by rearranging the required p.pdfThe algorithm to reverse a linked list by rearranging the required p.pdf
The algorithm to reverse a linked list by rearranging the required p.pdf
 
Splicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdf
Splicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdfSplicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdf
Splicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdf
 
since both are strong acids we can add up their individual contribut.pdf
since both are strong acids we can add up their individual contribut.pdfsince both are strong acids we can add up their individual contribut.pdf
since both are strong acids we can add up their individual contribut.pdf
 
public int getPosition(T anObject) { int result = null; result .pdf
public int getPosition(T anObject) { int result = null;  result .pdfpublic int getPosition(T anObject) { int result = null;  result .pdf
public int getPosition(T anObject) { int result = null; result .pdf
 

Recently uploaded

Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
cupulin
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 

Recently uploaded (20)

Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 

Hello,Ther is some problem in you codeI made my own programme as.pdf

  • 1. Hello, Ther is some problem in you code I made my own programme as per your requirement Please check my solution :- 1)Create one FIFO 2)From Client write character first and wait for some time so that server will read it 3) After wait for some time write integer Server programme :- --------------------------------------- #include #include #include #include #include int main() { int client_to_server; char *myfifo = "/tmp/client_to_server_fifo"; char str; int iteration; /* create the FIFO (named pipe) */ mkfifo(myfifo, 0666); /* open, read, and display the message from the FIFO */ client_to_server = open(myfifo, O_RDONLY); printf("Server ON. "); read(client_to_server, &str, sizeof(str)); read(client_to_server, &iteration, sizeof(iteration)); close(client_to_server); unlink(myfifo); //Now Print the character for(int i = 0; i < iteration ; i++){ printf("Iteration ::%d and Character:: %c ",i,str); }
  • 2. return 0; } Client Programme :- --------------------------------------- #include #include #include #include #include int main() { int client_to_server; char *myfifo = "/tmp/client_to_server_fifo"; char str; int iteration; printf("Client: Please enter a character: "); scanf("%c", &str); printf("Client: Please enter an integer: "); scanf("%d", &iteration); /* write str to the FIFO */ client_to_server = open(myfifo, O_WRONLY); //First write character write(client_to_server, &str, sizeof(str)); //wait for some time so that server will read character sleep(0.250); //Then write integer write(client_to_server, &iteration, sizeof(iteration)); perror("Write:"); //Very crude error check printf("...received from the server: %s ",str); close(client_to_server); /* remove the FIFO */ return 0; }
  • 3. Solution Hello, Ther is some problem in you code I made my own programme as per your requirement Please check my solution :- 1)Create one FIFO 2)From Client write character first and wait for some time so that server will read it 3) After wait for some time write integer Server programme :- --------------------------------------- #include #include #include #include #include int main() { int client_to_server; char *myfifo = "/tmp/client_to_server_fifo"; char str; int iteration; /* create the FIFO (named pipe) */ mkfifo(myfifo, 0666); /* open, read, and display the message from the FIFO */ client_to_server = open(myfifo, O_RDONLY); printf("Server ON. "); read(client_to_server, &str, sizeof(str)); read(client_to_server, &iteration, sizeof(iteration)); close(client_to_server); unlink(myfifo); //Now Print the character for(int i = 0; i < iteration ; i++){
  • 4. printf("Iteration ::%d and Character:: %c ",i,str); } return 0; } Client Programme :- --------------------------------------- #include #include #include #include #include int main() { int client_to_server; char *myfifo = "/tmp/client_to_server_fifo"; char str; int iteration; printf("Client: Please enter a character: "); scanf("%c", &str); printf("Client: Please enter an integer: "); scanf("%d", &iteration); /* write str to the FIFO */ client_to_server = open(myfifo, O_WRONLY); //First write character write(client_to_server, &str, sizeof(str)); //wait for some time so that server will read character sleep(0.250); //Then write integer write(client_to_server, &iteration, sizeof(iteration)); perror("Write:"); //Very crude error check printf("...received from the server: %s ",str); close(client_to_server); /* remove the FIFO */