Professional Documents
Culture Documents
http://www.ignouassignmentguru.com
Course Code : BCSL-056
Course Title: Network Programming and Administration Lab
Assignment Number : BCA (V)/L-056/Assignment/2016
April, 2016 (For January 2016 Session)
1. Write a TCP client and TCP server program in C language on UNIX operating system. The
client program begins by sending a request, after accepting the client request; server program
sends back a confirmation and its clock time to the client. Client program displays the server
clock time on its screen. The maximum concurrent clients this server can handle are four.
Display necessary messages, wherever necessary.
(20 marks)
Ans:
Header file Explanation
#ifdef HAVE_CONFIG_H
1
IGNOU ASSIGNMENT GURU Page-
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
/ignouassignmentfree
BCA & MCA (IGNOU)
http://www.ignouassignmentguru.com
int sockfd;
int len, rc ;
struct sockaddr_in address;
int result;
char ch = 'A';
if(result == -1)
{
perror("Error has occurred");
exit(-1);
}
/ignouassignmentfree
BCA & MCA (IGNOU)
http://www.ignouassignmentguru.com
printf("write rc = %d\n", rc ) ;
if (rc == -1) break ;
exit(0);
}
/// SERVER
//Remove any old socket and create an unnamed socket for the server.
server_sockfd = socket(AF_INET, SOCK_STREAM, 0);
server_address.sin_family = AF_INET;
/ignouassignmentfree
BCA & MCA (IGNOU)
http://www.ignouassignmentguru.com
server_address.sin_addr.s_addr = htons(INADDR_ANY);
server_address.sin_port = htons(7734) ;
server_len = sizeof(server_address);
client_len = sizeof(client_address);
client_sockfd = accept(server_sockfd, (struct sockaddr *) &client_address, &client_len);
printf("after accept()... client_sockfd = %d\n", client_sockfd) ;
while(1)
{
char ch;
printf("server waiting\n");
//Accept a connection
//client_len = sizeof(client_address);
//client_sockfd = accept(server_sockfd, (struct sockaddr *) &client_address, &client_len);
//printf("after accept()... client_sockfd = %d\n", client_sockfd) ;
//Read write to client on client_sockfd
4
IGNOU ASSIGNMENT GURU Page-
printf("server exiting\n");
//close(client_sockfd);
/ignouassignmentfree
BCA & MCA (IGNOU)
http://www.ignouassignmentguru.com
close(client_sockfd);
return 0;
}
2.
(a) Write the step by step procedure to configure a remote server and transfer a Directory to
Remote Server in Linux.
(10 marks)
Ans:
To configure access to the server in this set-up, you need to specify the following:
/ignouassignmentfree
BCA & MCA (IGNOU)
http://www.ignouassignmentguru.com
c. FTPS: choose this option to have PhpStorm access the server via the FTP file transfer
protocol over SSL (the FTPS extension).
d. When editing the server configuration name in the Name text box, use the Up and
Down keys on your keyboard to change the preselected server access to type in the
Protocol drop-down list.
D. Click OK. The Add Server dialog box closes and you return to the Connection tab of the
Deployment dialog box.
a. Click the Use as Default toolbar button.
Ftp server is used to transfer files between server and clients. All major operating system supports
ftp. ftp is the most used protocol over internet to transfer files. Like most Internet operations, FTP
works on a client/ server model. FTP client programs can enable users to transfer files to and from a
remote system running an FTP server program.
Configuring the ftp Server
The vsftpd RPM package is required to configure a Red Hat Enterprise Linux system as an ftp server.
If it is not already installed, install it with rpm commands as described in our pervious article. After it
is installed, start the service as root with the command service vsftpd start . The system is now an ftp
server and can accept connections. To configure the server to automatically start the service at boot
time, execute the command chkconfig vsftpd on as root. To stop the server, execute the command
service vsftpd stop. To verify that the server is running, use the command service vsftpd status.
(b) Write a step by step procedure to create and configure samba Server in Linux. Also,
transfer files from client side.
Ans:
Installing Samba
6
IGNOU ASSIGNMENT GURU Page-
For this part of the procedure, you'll use the su - (switch user) command to work as root. Although it’s
not best practice to do this regularly, there are times where it's much more practical to work directly as
root instead of trying to use sudo to do everything. This is one of those times.
You're going to create a new directory containing three empty files which you'll share using Samba.
/ignouassignmentfree
BCA & MCA (IGNOU)
http://www.ignouassignmentguru.com
2. While logged on as root, create the new directory /smbdemo with the following command:
mkdir /smbdemo
3. Change the permissions on the new directory to 770 with the following command:
cd /smbdemo
5. Add three empty files to the directory with the following command:
You must add users to the Samba database in order for them to have access to their home directory
and other Samba shares.
6. Use the following command to add a new Samba user (the new Samba user must be an existing
Linux user or the command will fail):
smbpasswd -a <username>
For example, to add the user don, use the command smbpasswd -a don.
7. Perform the following steps to create a smbusers group, change ownership of the /smbdemo
directory, and add a user to the smbusers group:
groupadd smbusers
chown :smbusers /smbdemo
usermod -G smbusers don
/ignouassignmentfree
BCA & MCA (IGNOU)
http://www.ignouassignmentguru.com
Configuring Samba
Note: In several of the steps in this exercise, I mention specific line numbers. The line numbers I
mention are based on CentOS version 6.5. If you’re running any other version, your line numbers may
be different. In that case, just search for the relevant text string.
Samba configuration is done in the file /etc/samba/smb.conf. There are two parts to
/etc/samba/smb.conf:
Global Settings: This is where you configure the server. You’ll find things like authentication
method, listening ports, interfaces, workgroup names, server names, log file settings, and
similar parameters.
Share Definitions: This is where you configure each of the shares for the users. By default,
there’s a printer share already configured.
Configuring smb.conf
8. In the Global Settings section, at line 74, change the workgroup name to your workgroup name.
I’m going to use soundtraining as a means of shamelessly promoting my company during your quest
for knowledge.
8
IGNOU ASSIGNMENT GURU Page-
/ignouassignmentfree