1. Course Code : BCSL-056
Title : Network Programming and Administration Lab
Assignment Number : BCA(V)-056/Assign/14-15
Maximum Marks : 50
Weightage : 25%
Last date of Submission : 15th October, 2014 (For July 2014 Session)
15th April, 2015 (For January 2015 Session)
Note: This assignment has two questions. Answer all the questions. These questions carry
40 marks. Rest 10 marks are for viva voce.
Question 1:
Write a UDP client and UDP server program in C language on UNIX operating system. A
client program starts the communication and sends a text string. Whenever server is free, it
can answer the client (however in case of multiple clients, server will respond on first come
first serve basis) and send reverse of the text string sent by the respective client.
Solution:
ECHO SERVER USING UDP
SERVER:
#include<netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include
#include <arpa/inet.h>
#include
#include
main()
{
int sfd,l;
char buf[1024]=”",buf1[1024]=”";
struct sockaddr_in ser;
sfd=socket(AF_INET,SOCK_DGRAM,0);
bzero(&ser,sizeof(ser));
ser.sin_family=AF_INET;
ser.sin_port=htons(1300);
inet_aton(“localhost”,&ser.sin_addr);
printf(“Enter the message:”);
scanf(“%s”,buf);
sendto(sfd,buf,strlen(buf),0,(struct sockaddr *)&ser,sizeof(ser));
recvfrom(sfd,buf1,1024,0,NULL,NULL);
close(sfd);
}
CLIENT:
#include<netinet/in.h>
#include <sys/types.h>
2. #include <sys/socket.h>
#include
#include <arpa/inet.h>
#include
#include
main()
{
int sfd,l;
char buf[1024]=”";
struct sockaddr_in server,client;
sfd=socket(AF_INET,SOCK_DGRAM,0);
bzero(&server,sizeof(server));
server.sin_family=AF_INET;
server.sin_port=htons(1300);
inet_aton(“localhost”,&server.sin_addr);
printf(“bind=%dn” ,bind(sfd,(struct sockaddr *)&server,sizeof(server)));
l=sizeof(client);
for(;;)
{
recvfrom(sfd,buf,1024,0,(struct sockaddr *)&client,&l);
sendto(sfd,buf,strlen(buf),0,(struct sockaddr *)&client,l);
printf(“MESSAGE FROM CLIENT:%sn”,buf);
}
}
OUTPUT:
SERVER:
cc udpechoserver.c -o echo
./echo
bind=0
MESSAGE FROM CLIENT:olleH
CLIENT:
cc udpechoclient.c -o udpecho
./udpecho
Enter the message:
Hello
Question 2:
a) Write the step by step procedure to configure and launch an FTP server than install and
test an FTP client in Linux.
click here to see the solution of Second Question
b) Write a step by step procedure to create and configure a remote server and transfer a
Directory to Remote Server.
3. Solution:
Connecting to the Remote Server
To make a connection to your remote server:
1. Switch to the Remote System Explorer perspective. From the workbench menu, click
Window > Open Perspective > Remote System Explorer.
2. In the Remote Systems view, New Connection is automatically expanded to show the
various remote systems you can connect to through the Remote System Explorer.
Expand Linux or Unix to invoke the new connection dialog box and configure a
connection.
3. Enter a name for your first profile and click Next. (This step only occurs if you have
never defined a connection before.)
4. Enter a connection name. This name displays in your tree view and must be unique to
the profile.
5. Enter the name or TCP/IP address of your Linux server in the Host name field, for
example, LINUX_A.
6. (Optional) Enter a Description. The description appears in the Properties view after
the connection is created.
7. Click Finish to define your system.
Attention: To check your port number, right-click your connection or subsystem from the
Remote Systems view and select Properties. Click Subsystem to view the relevant
information. If your port is “0,” then your Remote System Explorer communications
server will pick any free port on the server. If you specified a port number when starting
the server, you need to enter it here, for example, to work with a firewall.
1 Download a file from the FTP server to your computer. Navigate to the file or folder
that you want to download on the right side of the window. Navigate to the location that
you want to save it on the left side of the window. Click and drag the file from the bottom
frame on the right to the bottom frame on the left. Your file or folder will start transferring
automatically.
You can see the size of the file in bytes in the “Filesize” column.
You can select multiple files to download in the same session by holding ^ Ctrl and
clicking on each one you want. Files will be transferred one at a time.
You can add files to your download queue by right-clicking on them and selecting “Add
files to queue”
2 Upload a file to the server. Navigate to the file or folder that you want to upload on the
left side of the window. Navigate to the location that you want to upload it to on the right
side of the window. If you have permissions to upload a file to the FTP server, you can
click and drag the file from the left side to the right side to begin uploading.
Most public FTPs will not allow anonymous users to upload files.
Uploads will typically take longer than downloads of the same size.
3 Track your transfers. You can watch your transfers in the bottom frame of the window.
You will see a list of files you are transferring and have queued, along with their size,
priority, and percent completion. You can see your failed and completed transfers by
using the tabs at the bottom of the window.