0% found this document useful (0 votes)
184 views5 pages

Experiment 12B Aim: Program: Webserver: Fileserver

The document describes configuring and demonstrating FTP, web, and file servers on a network. It provides code to run an HTTP server using Python, install an FTP server using apt, and code for an FTP client in C. The output shows the HTTP server serving files and logging requests. It also shows logging into the FTP server, listing files, and exiting.

Uploaded by

Ajay Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
184 views5 pages

Experiment 12B Aim: Program: Webserver: Fileserver

The document describes configuring and demonstrating FTP, web, and file servers on a network. It provides code to run an HTTP server using Python, install an FTP server using apt, and code for an FTP client in C. The output shows the HTTP server serving files and logging requests. It also shows logging into the FTP server, listing files, and exiting.

Uploaded by

Ajay Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

EXPERIMENT 12b

Aim​: ​Configure the following services in the network- FTP server, Web server, File server -
Implementation and Demonstration

PROGRAM:

Webserver:
python3 -m http.server
Fileserver
Sudo apt install vsftpd

Ftpclient.c

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/socket.h>
#include<netinet/in.h>
#include<time.h>
#define PORT_FTP 21 /* FTP connection port */
#define SERVER_ADDR "192.168.1.6" /* localhost */
#define MAXBUF 1024

int main()
{ int sockfd;
struct sockaddr_in dest;
char buffer[MAXBUF];

/*---Open socket for streaming---*/


if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
{
perror("Socket");
exit(errno);
}

/*---Initialize server address/port struct---*/


bzero(&dest, sizeof(dest));
dest.sin_family = AF_INET;
dest.sin_port = htons(PORT_FTP);
if ( inet_aton(SERVER_ADDR, &dest.sin_addr.s_addr) == 0 )
{
perror(SERVER_ADDR);
exit(errno);
}

/*---Connect to server---*/
if ( connect(sockfd, (struct sockaddr*)&dest, sizeof(dest)) != 0 )
{
perror("Connect ");
exit(errno);
}

/*---Get "Hello?"---*/
bzero(buffer, MAXBUF);
recv(sockfd, buffer, sizeof(buffer), 0);
printf("%s", buffer);

/*---Clean up---*/
close(sockfd);
return 0;
}

OUTPUT
Webserver:
Firefox Output:

Fileserver:

Ftpclient.c:

OUTPUT FILE:
Webserver:
python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
127.0.0.1 - - [30/Mar/2020 13:37:02] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [30/Mar/2020 13:37:03] code 404, message File
not found
127.0.0.1 - - [30/Mar/2020 13:37:03] "GET /favicon.ico
HTTP/1.1" 404 -
127.0.0.1 - - [30/Mar/2020 13:37:04] "GET /webpage1.html
HTTP/1.1" 200 -
127.0.0.1 - - [30/Mar/2020 13:37:04] "GET
/css/bootstrap.min.css HTTP/1.1" 200
Fileserver:
ftp 192.168.1.6
Connected to 192.168.1.6.
220 (vsFTPd 3.0.3)
Name (192.168.1.6:tomcat): ftpuser
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r-- 1 1002 1002 8980 Apr 16 2018 examples.desktop
-rw-rw-r-- 1 1002 1002 14 Mar 30 11:21 hello.txt
226 Directory send OK.
ftp> exit
221 Goodbye.

FTPClient.c:
./ftpclient
220 (vsFTPd 3.0.3)

Readme:
Place the html files to be hosted in a single directory named
webserver. Navigate to webserver and run the following
command:
python3 -m http.server
Then, in the browser open 127.0.0.1:8000 and it will display the
webpage from that folder.
Install fileserver in ubuntu using the command:
sudo apt install vsftpd
After that find out the ip address of machine using ipconfig.
Type that ip address into ftpclient.c to test connection to ftp
server.

You might also like