Experiment 12B Aim: Program: Webserver: Fileserver
Experiment 12B Aim: Program: Webserver: Fileserver
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];
/*---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.