Warning: include(topsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/client_server.html on line 13

Warning: include(topsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/client_server.html on line 13

Warning: include(): Failed opening 'topsc.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eng123/public_html/sourcecode/c/unix/client_server.html on line 13

Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 


Warning: include(adsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/client_server.html on line 31

Warning: include(adsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/client_server.html on line 31

Warning: include(): Failed opening 'adsc.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eng123/public_html/sourcecode/c/unix/client_server.html on line 31

 
Client Server Program using FIFO

--------------------------------------------------------------------------------

Description : implement a single Client Server Program using FIFO

client.c
--------
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<fcntl.h>
#define FIFO1 "temp1"
#define FIFO2 "temp2"
#define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
void client(int r,int w)
{
int l,n;
char buf[80];
fgets(buf,80,stdin);
l=strlen(buf);
if(buf[l-1]=='
')
l--;
write(w,buf,l);
while((n=read(r,buf,80))>0)
write(STDOUT_FILENO,buf,n);
}
int main(int argc,char *argv[])
{
int readfd,writefd;
printf("Enter the File Name to Get:");
writefd=open(FIFO1,O_WRONLY,0);
readfd=open(FIFO2,O_RDONLY,0);
client(readfd,writefd);
close(readfd);
close(writefd);
}



server.c
--------


#include<stdio.h>
#include<unistd.h>
#include<errno.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<fcntl.h>
#define FIFO1 "temp1"
#define FIFO2 "temp2"
#define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
void server(int r,int w)
{
int fd,n;
char buf[81];
if((n=read(r,buf,80))==0)
{
return;
}
buf[n]='
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved copyright 123ENG