[Sender.c]
#include<stdio.h>#include<fcntl.h>
#include<string.h>
void main(int argc, char *args[])
{
int i,count=0,len,j=0,pid;
char frame[50],data[50];
len=strlen(args[1])-8;
system("clear");
system(">pipe");
pid=open("pipe",O_WRONLY);
printf("len : %d",len);
printf("%s",data);
for(i=0; i<len; i++)
{
data[i]=args[1][8+i];
}
data[i]='\0';
printf("data %s",data);
frame[j]=len+48;
for(i=0; i<len; i++)
{
j++;
frame[j]=data[i];
}
j++;
frame[j]='\0';
printf(" Sent to frame :%s",frame);
write(pid,&frame,sizeof(frame));
}
[Receiver.c]
#include<stdio.h>
#include<fcntl.h>
#include<string.h>
void main()
{
int i,count=0,len,j=0,pid;
char frame[50],data[50];
system("clear");
pid=open("pipe",O_RDONLY);
read(pid,&frame,sizeof(frame));
printf("%s",frame);
len=strlen(frame);
for(i=0; i<len; i++)
{
data[i]=frame[i+1];
}
data[i]='\0';
printf("data %s",data);
printf("\n receive to frame :%s",data);
}