Write a C program for PC to PC communication.

, by Prashant Gunjal

FILE TRANSFER 

Transmitter : 

#include<stdio.h>
#include<conio.h>
#include<bios.h>
#include<string.h>
#include<stdlib.h>
#include<process.h>
#define setting (0x80|0x02|0x00|0x00)
#define com1 0
void main(int argc,char *argv[])
{
char str[15],ch='\0';
int i=0;
FILE *fp;
clrscr();
strcpy(str,argv[1]);
i=strlen(str);
str[i]='\0';
if(argc!=2)
{
printf("error");
getch();
exit(1);
}
i=0;
bioscom(0,setting,com1);
while(str[i]!='\0')
{
bioscom(1,str[i],com1);

i++;
}
bioscom(1,'\0',com1);
fp=fopen(argv[1],"r");
while(!feof(fp))
{
    ch=fgetc(fp);
    bioscom(1,ch,com1);
printf("%c",ch);
}


fclose(fp);
bioscom(1,'\0',com1);
getch();
}

Receiver : 

//receiver
#include<stdio.h>
#include<conio.h>
#include<bios.h>
#include<dos.h>
#include<process.h>
#include<string.h>
#include<stdlib.h>
#define setting (0x80 | 0x02 | 0x00 | 0x00)
#define com1 0
void main()
{
int i=0;
char ch='\0',fr[20];
FILE *fp;
clrscr();
bioscom(0,setting,com1);
flushall();
do
{
ch=bioscom(2,0,0);            ; for receive no data direct receive
if(ch=='\0')
break;
if(ch!=0x20)
{
printf("%c",ch);
fr[i]=ch;
i++;
}
}while(1);
fr[i]='\0';
fp=fopen(fr,"w");
do
{
ch=bioscom(2,0,0);
if(ch=='\0')
break;
printf("%c",ch);
fputc(ch,fp);
}while(1);
getch();
}


**********************OUTPUT***********************
Trasnmitter :

  Hardware lab Experiment

Receiver :

  Hardware lab Experiment
  

0 comments: