FTP USING RS232 in Network Lab C++ Programming

To write a program for FTP using RS232 and to verify the text
entered in the file.
ALGORITHM FOR FTP USING RS232
STEP 1: Start the program.
STEP 2: Create a file pointer and a union.
STEP 3: Open another new file with a txt extension.
STEP 4: Enter some text in it and save the file.
STEP 5: Select an option from the choices.
STEP 6: The first option displays data ready.
STEP 7: The second option displays the text in the file.
STEP 8: Stop the program.
Source Coding in C++
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
#include<iostream.h>
#include<fstream.h>
void main()
{
FILE *fp;
char fname[25];
union REGS,a,b;
char al;
int op;
clrscr();
a.h.ah=0x00;
ax.dx=0;
a.h.al=0xcc;
int 86(0x11,&a,&b);
printf(“\n 1.SEND\n2. RECEIVE\n3. EXIT\n”);
do
{
printf(“\nEnter the option”);
scanf(“%d”,&op);
switch(op)
case 1:
printf(“Enter the file name”);
cin>>fname;
fp=fopen(fname,”r”);
if(fp==NULL0
printf(“\nERROr”);
getch();
exit(0);
}
a.h.al=0x01;
a.x.dx=0;
while(!feof(fp))
{
ch=getch(fp);
a.h.al=ch;
int 86(0x14,&a,&b);
a.h.al=ch;
int 86(0x14,&a,&b);
}
if(a.h.ah==0)
printf(“\nERROR”);
else
printf(”DATA READY”);
fclose(fp);
break;
case 2:
fp=fopen(fname,”r”);
if(fp==NULL)
{
printf(“\n ERROR”);
getch();
exit(0);
}
while(!feof(fp))
{
ch=getc(fp);
cout<<ch;
}
fclose(fp);
break;
case 3:
exit(0);
default:
printf(“Enter the correct option”);
}
}
while(op!=3)
getch()
}
INPUT OUTPUT FOR FTP RS232
1. SEND
2. RECEIVE
3. EXIT
Enter the option : 1
Enter the file name: ftp.txt
DATA READY
Enter the option: 2
Network programming lab
Enter the option: 3
ftp.txt
Network programming lab
RESULT Thus the program for FTP using RS232 is executed and the output
is verified. Free C programming Source code.

Post a Comment

0 Comments