DS Final
DS Final
I. Java.io Package
Provides for system input and output through data streams, serialization and the file system.
A) DataInputStream
A data input stream lets an application read primitive Java data types from an underlying
input stream in a machine-independent way. An application uses a data output stream to write
data that can later be read by a data input stream.
Reads from the stream in a representation of a Unicode character string encoded in modified
UTF-8 format; this string of characters is then returned as a String.
Parameters:
in - a data input stream.
Returns:
a Unicode string.
B) DataOutputStream
A data output stream lets an application write primitive Java data types to an output stream in
a portable way. An application can then use a data input stream to read the data back in.
Creates a new data output stream to write data to the specified underlying output stream. The
counter written is set to zero.
Parameters:
out - the underlying output stream, to be saved for later use.
Writes a string to the underlying output stream using modified UTF-8 encoding in a machine-
independent manner.
Parameters:
str - a string to be written.
II. Java.net Package
Provides the classes for implementing networking applications.
A) InetAddress
This class represents an Internet Protocol (IP) address.
1) public static InetAddress getByName(String host)
throws UnknownHostException
Determines the IP address of a host, given the host's name.
Parameters:
host - the specified host, or null.
Returns:
an IP address for the given host name.
B) Socket
This class implements client sockets (also called just "sockets"). A socket is an endpoint for
communication between two machines.
1) public Socket(String host, int port, InetAddress localAddr, int localPort)
throws IOException
Creates a socket and connects it to the specified remote host on the specified remote port. The
Socket will also bind() to the local address and port supplied.
Parameters:
host - the name of the remote host, or null for the loopback address.
port - the remote port
localAddr - the local address the socket is bound to, or null for the anyLocal address.
localPort - the local port the socket is bound to, or zero for a system selected free port.
Create a server with the specified port, listen backlog, and local IP address to bind to.
Parameters:
port - the port number, or 0 to use a port number that is automatically allocated.
backlog - requested maximum length of the queue of incoming connections.
bindAddr - the local InetAddress the server will bind to
Listens for a connection to be made to this socket and accepts it. The method blocks until a
connection is made.
Returns:
the new Socket
3) public void close() throws IOException
Closes this socket. Any thread currently blocked in accept() will throw a SocketException.
If this socket has an associated channel then the channel is closed as well.
Throws:
IOException - if an I/O error occurs when closing the socket.
D) DatagramPacket
This class represents a datagram packet.
Datagram packets are used to implement a connectionless packet delivery service. Each
message is routed from one machine to another based solely on information contained within
that packet. Multiple packets sent from one machine to another might be routed differently,
and might arrive in any order. Packet delivery is not guaranteed.
Constructs a datagram packet for sending packets of length with the offset to the specified
port number on the specified host. The length argument must be less than or equal
to buf.length.
Parameters:
buf - the packet data.
offset - the packet data offset.
length - the packet data length.
address - the destination address.
port - the destination port number.
Returns the data buffer. The data received or the data to be sent starts from the offset in the
buffer, and runs for length long.
Returns:
the buffer used to receive or send data
3) public InetAddress getAddress()
Returns the IP address of the machine to which this datagram is being sent or from which the
datagram was received.
Returns:
the IP address of the machine to which this datagram is being sent or from which the
datagram was received.
4) public int getPort()
Returns the port number on the remote host to which this datagram is being sent or from
which the datagram was received.
Returns:
the port number on the remote host to which this datagram is being sent or from
which the datagram was received.
E) DatagramSocket
This class represents a socket for sending and receiving datagram packets.
A datagram socket is the sending or receiving point for a packet delivery service. Each packet
sent or received on a datagram socket is individually addressed and routed. Multiple packets
sent from one machine to another may be routed differently, and may arrive in any order.
Sends a datagram packet from this socket. The DatagramPacket includes information
indicating the data to be sent, its length, the IP address of the remote host, and the port
number on the remote host.
Parameters:
p - the DatagramPacket to be sent.
Java Remote Method Invocation (Java RMI) enables the programmer to create distributed
Java technology-based to Java technology-based applications, in which the methods of
remote Java objects can be invoked from other Java virtual machines, possibly on different
hosts. RMI uses object serialization to marshal and unmarshal parameters and does not
truncate types, supporting true object-oriented polymorphism.
A) Remote (Interface)
The Remote interface serves to identify interfaces whose methods may be invoked from a
non-local virtual machine. Any object that is a remote object must directly or indirectly
implement this interface. Only those methods specified in a "remote interface", an interface
that extends java.rmi.Remote are available remotely.
B) RemoteException
A RemoteException is the common superclass for a number of communication-related
exceptions that may occur during the execution of a remote method call. Each method of a
remote interface, an interface that extends java.rmi.Remote, must list RemoteException in its
throws clause
C) java.rmi.server.UnicastRemoteObject
Used for exporting a remote object with JRMP and obtaining a stub that communicates to the
remote object. Stubs are either generated at runtime using dynamic proxy objects, or they are
generated statically at build time, typically using the rmic tool.
D) Naming
The Naming class provides methods for storing and obtaining references to remote objects in
a remote object registry. Each method of the Naming class takes as one of its arguments a
name that is a java.lang.String in URL format (without the scheme component) of the form:
//host:port/name
where host is the host (remote or local) where the registry is located, port is the port number
on which the registry accepts calls, and where name is a simple string uninterpreted by the
registry.
1) public static void bind(String name, Remote obj)
throws AlreadyBoundException,
MalformedURLException,
RemoteException
Returns a reference, a stub, for the remote object associated with the specified name.
Parameters:
name - a name in URL format (without the scheme component)
Returns:
a reference for a remote object
E) java.rmi.registry.LocateRegistry
LocateRegistry is used to obtain a reference to a bootstrap remote object registry on a
particular host (including the local host), or to create a remote object registry that accepts
calls on a specific port.
Creates and exports a Registry instance on the local host that accepts requests on the
specified port.
Parameters:
port - the port on which the registry accepts requests
Returns:
the registry
IV. org.apache.commons.net.ftp Package
Contains FTP and FTPS support classes
A) FTPClient
FTPClient encapsulates all the functionality necessary to store and retrieve files from an FTP
server. This class takes care of all low level details of interacting with an FTP server and
provides a convenient higher level interface.
1) public FTPClient()
Default FTPClient constructor.
2) public void connect(InetAddress host) throws SocketException, IOException
Opens a Socket connected to a remote host at the current default port and originating
from the current host at a system assigned port. Before returning, _connectAction_() is
called to perform connection initialization actions.
Parameters:
host - The remote host.
3) public int getReplyCode()
Returns the integer value of the reply code of the last FTP reply. You will usually only
use this method after you connect to the FTP server to check that the connection was
successful since connect is of type void.
Returns:
The integer value of the reply code of the last FTP reply.
throws IOException
Retrieves a named file from the server and writes it to the given OutputStream.
Parameters:
remote - The name of the remote file.
local - The local OutputStream to which to write the file.
Returns:
True if successfully completed, false if not.
B) FTPReply
FTPReply stores a set of constants for FTP reply codes.
1) public static boolean isPositiveCompletion(int reply)
Determine if a reply code is a positive completion response. All codes beginning with a 2 are
positive completion responses. The FTP server will send a positive completion response on
the final successful completion of a command.
Parameters:
reply - The reply code to test.
Returns:
True if a reply code is a postive completion response, false if not.
C)FTPFile
The FTPFile class is used to represent information about files stored on an FTP server.
1) public String getName()
Return the name of the file.
Returns:
The name of the file.
V. java.sql Package
Provides the API for accessing and processing data stored in a data source (usually a
relational database) using the JavaTM programming language.
A) Connection (Interface)
A connection (session) with a specific database. SQL statements are executed and results are
returned within the context of a connection.
Creates a Statement object for sending SQL statements to the database. SQL statements
without parameters are normally executed using Statement objects.
Returns:
a new default Statement object
2) void close() throws SQLException
Releases this Connection object's database and JDBC resources immediately instead of
waiting for them to be automatically released.
B) DriverManager
The basic service for managing a set of JDBC drivers. As part of its initialization, the
DriverManager class will attempt to load the driver classes referenced in the "jdbc.drivers"
system property. This allows a user to customize the JDBC Drivers used by their applications.
1) public static Connection getConnection(String url,String user,String password)
throws SQLException
Attempts to establish a connection to the given database URL. The DriverManager attempts
to select an appropriate driver from the set of registered JDBC drivers.
Parameters:
url - a database url of the form jdbc:subprotocol:subname
user - the database user on whose behalf the connection is being made
password - the user's password
Returns:
a connection to the URL
C) Statement (Interface)
The object used for executing a static SQL statement and returning the results it produces.
1) ResultSet executeQuery(String sql) throws SQLException
Executes the given SQL statement, which returns a single ResultSet object.
Note:This method cannot be called on a PreparedStatement or CallableStatement.
Parameters:
sql - an SQL statement to be sent to the database, typically a static SQL SELECT
statement
Returns:
a ResultSet object that contains the data produced by the given query; never null
D) ResultSet (Interface)
A table of data representing a database result set, which is usually generated by executing a
statement that queries the database.
Retrieves the number, types and properties of this ResultSet object's columns.
Returns:
the description of this ResultSet object's columns
An Echo Service is a Service which always returns back the same message that it receives from the
client.
Input:
IP Address – 10.2.0.5
Port No. -- 7
Message -- XYZ
Output:
The message sent to the server is sent back as a response.
Packages Used:
• java.io.*;
• java.net.*;
• DatagramPacket
o DatagramPacket()
• InetAddress
o getByName()
Program:
package udpwellknown42;
import java.io.*;
import java.net.*;
ds.send(sndPacket);
ds.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Output Images:
PROGRAM - 2
Program Statement:
Implement a GUI based TCP Client program for Well Known Service – Echo.
An Echo Service is a Service which always returns back the same message that it receives from the
client.
Input:
IP Address – 10.2.0.5
Port No. -- 7
Message -- XYZ
Output:
The message sent to the server is sent back as a response.
Packages Used:
• java.io.*;
• java.net.*;
try{
Socket s = new Socket(InetAddress.getByName(ip), port);
DataInputStream dis = new DataInputStream(s.getInputStream());
dos.writeUTF(msg);
String response = dis.readUTF();
ServerResponse.append("Echo: " + msg + "\n");
s.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}
Output Images:
PROGRAM - 3
Program Statement:
Implement a GUI based UDP Client – Server program for Echo Service.
An Echo Service is a Service which always returns back the same message that it receives from the
client.
Input:
IP Address – localhost
Message -- XYZ
Output:
The message sent to the server is sent back as a response.
Packages Used:
• java.io.*;
• java.net.*;
import java.io.*;
import java.net.*;
try {
DatagramSocket ds = new DatagramSocket();
ds.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Server:
package udpapplication42;
import java.io.*;
import java.net.*;
public class UDPServer extends javax.swing.JFrame implements Runnable{
private void StartButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Thread thread = new Thread(this, "server");
StartButton.setEnabled(false);
thread.start();
MessageArea.append("Server Started");
}
@Override
public void run() {
String ipAddress = IPField.getText();
int portNo = Integer.parseInt(PortField.getText());
try {
DatagramSocket ds = new DatagramSocket(portNo,
InetAddress.getByName(ipAddress));
while(true) {
byte[] rcvMessage = new byte[40];
DatagramPacket rcvPacket = new DatagramPacket(rcvMessage,
40);
ds.receive(rcvPacket);
//ds.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Output Images:
PROGRAM - 4
Program Statement:
Implement a GUI based TCP Client – Server program for Echo Service.
An Echo Service is a Service which always returns back the same message that it receives from the
client.
Input:
IP Address – localhost
Message -- XYZ
Output:
The message sent to the server is sent back as a response.
Packages Used:
• java.io.*;
• java.net.*;
Program:
Client:
package tcpclientserverby42;
import java.net.*;
import java.io.*;
try{
Socket s = new Socket(InetAddress.getByName(ip), port);
DataInputStream dis = new DataInputStream(s.getInputStream());
dos.writeUTF(msg);
String response = dis.readUTF();
ServerResponse.append(msg + "\n");
s.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}
Server:
package tcpclientserverby42;
import java.net.*;
import java.io.*;
import java.lang.Runnable;
}
@Override
public void run() {
String ip = IPAddressField.getText();
int port = Integer.parseInt(PortNumber.getText());
try{
while(true){
Socket s = ss.accept();
catch(Exception e){
e.printStackTrace();
}
}
}
Output Images:
PROGRAM - 5
Program Statement:
Implement a GUI based Client – Server program for Bulletin Board Application.
Input:
IP Address – localhost
Message -- XYZ
Output:
The messages sent by multiple clients to bulletin server are displayed at the server.
Packages Used:
• java.io.*;
• java.net.*;
Program:
Client:
package bulletinboardby42;
import java.net.*;
import java.io.*;
try{
Socket s = new Socket(InetAddress.getByName(ip), port);
dos.writeUTF(msg);
String res = dis.readUTF();
ResponseArea.append(res + "\n");
s.close();
}
catch(Exception e){
e.printStackTrace();
}
}
Server:
package bulletinboardby42;
import java.net.*;
import java.io.*;
import java.lang.Runnable;
public class BulletinBoardServer extends javax.swing.JFrame implements
Runnable{
private void StartServerButtonActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
@Override
public void run(){
String ip = IPField.getText();
int port = Integer.parseInt(PortField.getText());
try{
while(true){
Socket s = ss.accept();
ResponseArea.append("\n" + announcement);
dos.writeUTF("Received Message");
s.close();
}
}
catch(Exception e){
e.printStackTrace();
}
}
}
}
Output Images:
PROGRAM - 6
Program Statement:
Implement a GUI based Client – Server program for Name Service/DNS Application.
A DNS server is a computer server that contains a database of public IP addresses and their
associated hostnames, and in most cases serves to resolve, or translate, those names to IP addresses
as requested.
Input:
IP Address – localhost
URL – www.abc.com
Output:
The Client sends a URL to the server and gets its Ip address as response.
Packages Used:
• java.io.*
• java.net.*
Program:
Server:
package nameserver42;
import java.io.*;
import java.net.*;
import java.util.Scanner;
import java.lang.Runnable;
try{
ServerSocket ss = new ServerSocket(portNo, 5,
InetAddress.getByName(ipAddress));
while(true){
try(
Socket s = ss.accept();
File f = new
File("C:\\Users\\admin\\Desktop\\NameServer42\\src\\nameserver42\\data.txt
");
Scanner scanner = new Scanner(f);
while(scanner.hasNextLine()){
String[] tokens = scanner.nextLine().split(" ");
if(url.equals(tokens[1])){
dos.writeUTF(tokens[0]);
found = true;
}
}
if(!found){
dos.writeUTF("Not Found");
}
} catch(Exception e) {
e.printStackTrace();
}
} catch(Exception e) {
e.printStackTrace();
} //To change body of generated methods, choose Tools | Templates.
}
}
Client:
package nameserver42;
import java.net.*;
import java.io.*;
try{
Socket s = new Socket(InetAddress.getByName(ipAddress),
portNo);
dos.writeUTF(url);
serverResponseArea.append(url);
String response = dis.readUTF();
serverResponseArea.append(": " + response +"\n");
s.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
Output Images:
PROGRAM - 7
Program Statement:
Implement a GUI based Client – Server program for Chat application.
The server listens for incoming connections from clients on a specified IP address and port number.
When a client connects, the server creates a new socket for the client, reads messages sent by the
client using a DataInputStream, and writes responses to the client using a DataOutputStream. The
server also displays the received messages in a text area on the GUI.
The client connects to the server using the specified IP address and port number. The client also uses
a DataInputStream and DataOutputStream to read and write messages to the server. The client also
has a text field on the GUI where the user can enter a message to send to the server. Additionally,
the client displays the sent messages in a text area on the GUI.
The Start button on the GUI starts the server thread, and the Send button sends messages from the
client to the server. The Exit button closes the connection between the client and server and closes
the program.
Chat Application refers to an Application which allows the process of communicating, interacting
and/or exchanging messages over the Internet. It involves two or more individuals that communicate
with each other in real time.
Input:
Client1 Client2
IP Address – localhost IP Address – localhost
Output:
The message sent by client 1 is received by server of client2 and the message sent by client 2
is received by server of client 1.
Packages Used:
• java.io.*
• java.net.*
Classes and Methods Used:
• Socket
o Socket()
o getInputStream()
o getOutputStream()
o close()
• DataInputStream
o readUTF()
• DataOutputStream
o writeUTF()
• ServerSocket
o ServerSocket()
o accept()
• InetAddress
o getByName()
Program:
package chatserverclientby42;
import java.net.*;
import java.io.*;
import java.lang.Runnable;
@Override
public void run(){
String ip = ServerIPField.getText();
int port = Integer.parseInt(ServerPortField.getText());
try{
ServerSocket ss = new ServerSocket(port, 5,
InetAddress.getByName(ip));
while(true){
Socket s = ss.accept();
DataInputStream dis = new DataInputStream(s.getInputStream());
DataOutputStream dos = new
DataOutputStream(s.getOutputStream());
String receivedMessage = dis.readUTF();
s.close();
}
}catch(Exception e){
e.printStackTrace();
}
}
private void SendButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String ip = ClientIPField.getText();
int port = Integer.parseInt(ClientPortField.getText());
try{
} catch(Exception e){
e.printStackTrace();
}
}
}
Output Images:
PROGRAM - 8 (a)
Program Statement:
Implement a RPC program for Echo Service.
1. The client procedure calls the client stub in the normal way.
2. The client stub builds a message and calls the local operating system.
5. The server stub unpacks the parameters and calls the server.
6. The server does the work and returns the result to the stub.
7. The server stub packs it in a message and calls its local as.
10. The stub unpacks the result and returns to the client
This is a program in c which uses Sun-RPC (Remote Procedure Call) library to implement Echo
Service. Here the client sends a message by making a function call to a remote procedure present on
the server. As an Echo Service, the server sends back the same message as a response.
Input:
A message to send to the server.
Output:
The message sent to server is sent back as response.
Program:
Specification file
program echo_prg{
version echo_ver{
string echo(string)=1;
}=1;
}=0x20000021;
Client
#include "echo.h"
void
echo_prg_1(char *host)
{
CLIENT *clnt;
char * *result_1;
char * echo_1_arg;
#ifndef DEBUG
clnt = clnt_create (host, echo_prg, echo_ver, "udp");
if (clnt == NULL) {
clnt_pcreateerror (host);
exit (1);
}
#endif /* DEBUG */
echo_1_arg=(char*)malloc(sizeof(char)*25);
printf("\nEnter a message:");
scanf("%s",echo_1_arg);
*result_1=(char*)malloc(sizeof(char)*25);
result_1 = echo_1(&echo_1_arg, clnt);
if (result_1 == (char **) NULL) {
clnt_perror (clnt, "call failed");
}
printf("result=%s",*result_1);
#ifndef DEBUG
clnt_destroy (clnt);
#endif /* DEBUG */
}
int
main (int argc, char *argv[])
{
char *host;
if (argc < 2) {
printf ("usage: %s server_host\n", argv[0]);
exit (1);
}
host = argv[1];
echo_prg_1 (host);
exit (0);
}
Server
#include "echo.h"
#include<string.h>
char **
echo_1_svc(char **argp, struct svc_req *rqstp)
{
static char * result;
result=(char*)malloc(sizeof(char)*25);
strcpy(result,*argp);
return &result;
}
Output Images:
PROGRAM - 8 (b)
Program Statement:
Implement a RPC program for Reversing a given String.
Input:
A message to send to the server.
Output:
The message sent to server is reversed and sent back as response.
Program:
Specification file
program rev_prog{
version rev_ver{
string revstr(string)=1;
}=1;
}=0x20000022;
Client
#include "rev.h"
void
rev_prog_1(char *host)
{
CLIENT *clnt;
char * *result_1;
char * revstr_1_arg;
#ifndef DEBUG
clnt = clnt_create (host, rev_prog, rev_ver, "udp");
if (clnt == NULL) {
clnt_pcreateerror (host);
exit (1);
}
#endif /* DEBUG */
revstr_1_arg=(char*)malloc(sizeof(char)*20);
printf("\nEnter a string:");
scanf("%s",revstr_1_arg);
*result_1=(char*)malloc(sizeof(char)*20);
result_1 = revstr_1(&revstr_1_arg, clnt);
if (result_1 == (char **) NULL) {
clnt_perror (clnt, "call failed");
}
printf("result=%s",*result_1);
#ifndef DEBUG
clnt_destroy (clnt);
#endif /* DEBUG */
}
int
main (int argc, char *argv[])
{
char *host;
if (argc < 2) {
printf ("usage: %s server_host\n", argv[0]);
exit (1);
}
host = argv[1];
rev_prog_1 (host);
exit (0);
}
Server
#include "rev.h"
#include<string.h>
#include<stdlib.h>
char **
revstr_1_svc(char **argp, struct svc_req *rqstp)
{
static char * result;
int i,j;
result=(char*)malloc(sizeof(char)*20);
for(j=0,i=strlen(*argp)-1;i>=0;i--,j++)
*(result+j)=*(*argp+i);
*(result+j)='\0';
return &result;
}
Output Images:
PROGRAM - 8 (c)
Program Statement:
Implement a RPC program for Concatenating two given Strings.
Input:
Two strings to be concatenated.
Output:
Concatenated String is sent back as response.
Program:
Specification file
struct strs{
string str1<>;
string str2<>;
};
program concat_prog{
version concat_ver{
string concat(strs)=1;
}=1;
}=0x20000201;
Client
#include "concat.h"
void
concat_prog_1(char *host)
{
CLIENT *clnt;
char * *result_1;
strs concat_1_arg;
#ifndef DEBUG
clnt = clnt_create (host, concat_prog, concat_ver, "udp");
if (clnt == NULL) {
clnt_pcreateerror (host);
exit (1);
}
#endif /* DEBUG */
concat_1_arg.str1=(char*)malloc(sizeof(char)*32);
concat_1_arg.str2=(char*)malloc(sizeof(char)*32);
printf("\nEnter two string to concatenate:");
scanf("%s%s",concat_1_arg.str1,concat_1_arg.str2);
*result_1=(char*)malloc(sizeof(char)*100);
result_1 = concat_1(&concat_1_arg, clnt);
if (result_1 == (char **) NULL) {
clnt_perror (clnt, "call failed");
}
printf("\nresult=%s",*result_1);
#ifndef DEBUG
clnt_destroy (clnt);
#endif /* DEBUG */
}
int
main (int argc, char *argv[])
{
char *host;
if (argc < 2) {
printf ("usage: %s server_host\n", argv[0]);
exit (1);
}
host = argv[1];
concat_prog_1 (host);
exit (0);
}
Server
#include "concat.h"
#include<string.h>
char **
concat_1_svc(strs *argp, struct svc_req *rqstp)
{
static char * result;
result=(char*)malloc(sizeof(char)*100);
strcpy(result,argp->str1);
strcat(result,argp->str2);
return &result;
}
Output Images:
PROGRAM - 8 (d)
Program Statement:
Implement a RPC program to find length of a given String.
Input:
A message to send to the server.
Output:
The length of the message is sent back as response.
Program:
Specification file
program strl_prog{
version strl_ver{
int strl(string)=1;
}=1;
}=0x20000022;
Client
#include "strl.h"
void
strl_prog_1(char *host)
{
CLIENT *clnt;
int *result_1;
char * strl_1_arg;
#ifndef DEBUG
clnt = clnt_create (host, strl_prog, strl_ver, "udp");
if (clnt == NULL) {
clnt_pcreateerror (host);
exit (1);
}
#endif /* DEBUG */
strl_1_arg=(char*)malloc(sizeof(char)*40);
printf("\nEnter a string:");
scanf("%s",strl_1_arg);
printf("\n input string is %s\n",strl_1_arg);
result_1=(int*)malloc(sizeof(int));
result_1 = strl_1(&strl_1_arg, clnt);
if (result_1 == (int *) NULL) {
clnt_perror (clnt, "call failed");
}
printf("length of %s is %d",strl_1_arg,*result_1);
#ifndef DEBUG
clnt_destroy (clnt);
#endif /* DEBUG */
}
int
main (int argc, char *argv[])
{
char *host;
if (argc < 2) {
printf ("usage: %s server_host\n", argv[0]);
exit (1);
}
host = argv[1];
strl_prog_1 (host);
exit (0);
}
Server
#include "strl.h"
#include<string.h>
int *
strl_1_svc(char **argp, struct svc_req *rqstp)
{
static int result;
result=strlen(*argp);
return &result;
}
Output Images:
PROGRAM - 8 (e)
Program Statement:
Implement a RPC program to find GCD of two given numbers.
Input:
Two numbers whose GCD has to be computed.
Output:
The GCD of the two numbers is sent back as response.
Program:
Specification file
struct num{
int a;
int b;
};
program gcd_prog{
version gcd_ver{
int gcd(num)=1;
}=1;
}=0x20000021;
Client
#include "gcd.h"
void
gcd_prog_1(char *host)
{
CLIENT *clnt;
int *result_1;
num gcd_1_arg;
#ifndef DEBUG
clnt = clnt_create (host, gcd_prog, gcd_ver, "udp");
if (clnt == NULL) {
clnt_pcreateerror (host);
exit (1);
}
#endif /* DEBUG */
printf("\nEnter two numbers:");
scanf("%d%d",&gcd_1_arg.a,&gcd_1_arg.b);
result_1 = gcd_1(&gcd_1_arg, clnt);
if (result_1 == (int *) NULL) {
clnt_perror (clnt, "call failed");
}
printf("\ngcd of %d and %d is
%d",gcd_1_arg.a,gcd_1_arg.b,*result_1);
#ifndef DEBUG
clnt_destroy (clnt);
#endif /* DEBUG */
}
int
main (int argc, char *argv[])
{
char *host;
if (argc < 2) {
printf ("usage: %s server_host\n", argv[0]);
exit (1);
}
host = argv[1];
gcd_prog_1 (host);
exit (0);
}
Server
#include "gcd.h"
int *
gcd_1_svc(num *argp, struct svc_req *rqstp)
{
static int result;
int temp;
while(argp->a!=0)
{
temp=argp->a;
argp->a=argp->b%argp->a;
argp->b=temp;
}
result=argp->b;
return &result;
}
Output Images:
PROGRAM - 8 (f)
Program Statement:
Implement a RPC program to find the sum of two given numbers.
Input:
Two numbers whose sum has to be computed.
Output:
The sum of the two numbers is sent back as response.
Program:
Specification file
struct num{
int a;
int b;
};
program add_prog{
version add_ver{
int add(num)=1;
}=1;
}=0x20000022;
Client
#include "add.h"
void
add_prog_1(char *host)
{
CLIENT *clnt;
int *result_1;
num add_1_arg;
#ifndef DEBUG
clnt = clnt_create (host, add_prog, add_ver, "udp");
if (clnt == NULL) {
clnt_pcreateerror (host);
exit (1);
}
#endif /* DEBUG */
printf("\nEnter two numbers:");
scanf("%d%d",&add_1_arg.a,&add_1_arg.b);
result_1=(int*)malloc(sizeof(int));
result_1 = add_1(&add_1_arg, clnt);
if (result_1 == (int *) NULL) {
clnt_perror (clnt, "call failed");
}
printf("\n %d + %d = %d",add_1_arg.a,add_1_arg.b,*result_1);
#ifndef DEBUG
clnt_destroy (clnt);
#endif /* DEBUG */
}
int
main (int argc, char *argv[])
{
char *host;
if (argc < 2) {
printf ("usage: %s server_host\n", argv[0]);
exit (1);
}
host = argv[1];
add_prog_1 (host);
exit (0);
}
Server
#include "add.h"
int *
add_1_svc(num *argp, struct svc_req *rqstp)
{
static int result;
result=argp->a+argp->b;
return &result;
}
Output Images:
PROGRAM - 9 (a)
Program Statement:
Implement a RMI program for Echo Service
The EchoInterface interface defines a single Remote Method, echo(String s), which takes in a string
as a parameter and returns the same string.
The EchoImpl class is the Implementation of the EchoInterface. The class extends
UnicastRemoteObject, which is necessary for objects that are exported to use RMI. The echo method
in this class takes in a string as a parameter, prints it out, and returns the same string.
The EchoServer class is the Server-Side Component of the Application. The main method of this class
creates an instance of EchoImpl, creates an RMI registry on a specified port, and binds the EchoImpl
object to a location in the registry.
The EchoClient class is the Client-Side Component of the Application. The main method of this class
looks up the EchoImpl object in the RMI registry using the specified location, prompts the user for
input and sends it to the echo method of the EchoImpl object, and prints out the response received
from the server.
To run the application, the server must be started first, followed by the client. The server and client
both take in three command-line arguments: the IP address of the server, the port number of the
RMI registry, and the name to bind the EchoImpl object to in the registry.
Input:
A message to send to the server.
Output:
The message sent to server is sent back as response.
Packages Used:
• java.rmi.*
• java.io.*
• java.net.*
• java.rmi.server.*
Classes and Methods Used:
• LocateRegistry
o createRegistry()
• Naming
o bind()
o lookup()
• Remote
• RemoteException
• MalformedURLException
• UnicastRemoteObject
Program:
Interface:
import java.rmi.Remote;
import java.rmi.RemoteException;
Implementation:
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
Server:
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.Naming;
import java.net.MalformedURLException;
import java.rmi.registry.LocateRegistry;
Client:
import java.rmi.*;
import java.io.*;
import java.net.MalformedURLException;
Output Images:
PROGRAM - 9 (b)
Program Statement:
Implement a RMI program for Reversing a given String.
The ReverseInterface interface defines a Single Remote method, reverseStr(String s), which takes in a
string as a parameter and returns the Reverse of the String.
The ReverseImpl class is the implementation of the ReverseInterface. The class extends
UnicastRemoteObject, which is necessary for objects that are exported to use RMI. The reverseStr
method in this class takes in a string as a parameter, creates a StringBuilder object with the input
string, reverses the string using the StringBuilder's reverse() method, and returns the reversed string.
The ReverseServer class is the Server-Side Component of the Application. The main method of this
class creates an instance of ReverseImpl, creates an RMI registry on the specified port, binds the
object to the registry, and makes it available for remote clients to access.
The ReverseClient class is the Client-Side Component of the Application. The main method of this
class looks up the remote object on the specified IP address, port and service name, prompts the
user to enter a string, calls the reverseStr method on the remote object, and prints the response.
The client and server communicate using RMI, which allows the client to invoke methods on the
remote object as if they were local methods. The client sends the string to the server, the server
reverses the string and sends the reversed string back to the client, which then prints it.
Input:
A message to send to the server.
Output:
The message sent to server is reversed and sent back as response.
Packages Used:
• java.rmi.*
• java.io.*
• java.net.*
• java.rmi.server.*
Classes and Methods Used:
• LocateRegistry
o createRegistry()
• Naming
o bind()
o lookup()
• Remote
• RemoteException
• MalformedURLException
• UnicastRemoteObject
Program:
Interface:
import java.rmi.Remote;
import java.rmi.RemoteException;
Implementation:
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
Server:
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.Naming;
import java.net.MalformedURLException;
import java.rmi.registry.LocateRegistry;
public class ReverseServer{
public ReverseServer() throws RemoteException{
}
public static void main(String args[]) throws RemoteException
{
ReverseImpl reverseObj=new ReverseImpl();
int port=Integer.parseInt(args[1]);
try{
LocateRegistry.createRegistry(port);
System.out.println("\n RMI registry created \n");
String host=args[0];
String bindLocation="//"+host+":"+port+"/"+args[2];
Naming.bind(bindLocation,reverseObj);
System.out.println("\nRMI server ready at "+bindLocation);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
Client:
import java.rmi.*;
import java.io.*;
import java.net.MalformedURLException;
Output Images:
PROGRAM - 9 (c)
Program Statement:
Implement a RMI program for Concatenating two given Strings.
The interface, ConcatInterface, defines the methods that can be called remotely by the client. In this
case, the method concatenate(String s1, String s2) is defined.
The implementation, ConcatImpl, provides the actual implementation of the methods defined in the
interface. ConcatImpl extends UnicastRemoteObject, and implements the ConcatInterface.
The server, ConcatServer, creates an instance of the ConcatImpl class and makes it available to the
client through the RMI registry. The server also creates the RMI registry on the specified port and
binds the ConcatImpl object to the location specified in the command line arguments.
The client, ConcatClient, looks up the ConcatImpl object on the RMI registry and invokes the
concatenate method, passing two strings as arguments. It receives the concatenated string as the
response from the server.
To run the RMI system, first, the server needs to be started, and then the client. The client connects
to the server and invokes the remote method by passing the required arguments. The server send
backs the concatenated string, i.e., end of first string joined to the start of the second string.
Input:
Two strings to send to the server.
Output:
The concatenated is sent back as response.
Packages Used:
• java.rmi.*
• java.io.*
• java.net.*
• java.rmi.server.*
Classes and Methods Used:
• LocateRegistry
o createRegistry()
• Naming
o bind()
o lookup()
• Remote
• RemoteException
• MalformedURLException
• UnicastRemoteObject
Program:
Interface:
import java.rmi.Remote;
import java.rmi.RemoteException;
Implementation:
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
Server:
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.Naming;
import java.net.MalformedURLException;
import java.rmi.registry.LocateRegistry;
Client:
import java.rmi.*;
import java.io.*;
import java.net.MalformedURLException;
Output Images:
PROGRAM - 9 (d)
Program Statement:
Implement a RMI program to find length of a given String.
The "LengthClient" class connects to the RMI server at the specified location, gets the remote
reference to the "LengthImpl" object and invokes the "strLength" method by passing a string as an
argument. The response returned by the server is the length of the string, which is then printed on
the client side.
Input:
A message to send to the server.
Output:
The length of the message is sent back as response.
Packages Used:
• java.rmi.*
• java.io.*
• java.net.*
• java.rmi.server.*
Implementation:
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
Server:
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.Naming;
import java.net.MalformedURLException;
import java.rmi.registry.LocateRegistry;
Client:
import java.rmi.*;
import java.io.*;
import java.net.MalformedURLException;
The GcdServer class creates an instance of GcdImpl and binds it to a location in the RMI registry, so
that it can be located by clients. The main method of GcdServer takes three command-line
arguments: the hostname, port number and the service name, which are used to construct the bind
location of the GcdImpl object in the RMI registry.
The GcdClient class looks up the GcdImpl object in the RMI registry using the same hostname, port
number and service name, and invokes the gcd() method on it. The client takes two input numbers
from the user and sends them to the remote method. The response from the remote method is the
GCD of these two numbers, which is displayed to the user.
Input:
Two numbers to send to the server.
Output:
The GCD of the two numbers is sent back as response.
Packages Used:
• java.rmi.*
• java.io.*
• java.net.*
• java.rmi.server.*
Implementation:
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
Client:
import java.rmi.*;
import java.io.*;
import java.net.MalformedURLException;
Output Images:
PROGRAM - 9 (f)
Program Statement:
Implement a RMI program to find the sum of two given numbers.
Input:
Two numbers to send to the server.
Output:
The sum of the two numbers is sent back as response.
Packages Used:
• java.rmi.*
• java.io.*
• java.net.*
• java.rmi.server.*
Implementation:
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
Server:
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.Naming;
import java.net.MalformedURLException;
import java.rmi.registry.LocateRegistry;
Client:
import java.rmi.*;
import java.io.*;
import java.net.MalformedURLException;
FTP File Listing Operation connects to an FTP Server and generates a list of files present in the
current working directory of the FTP Login.
This code is for a Java Swing Application that connects to an FTP server using the Apache Commons
Net library. When the user clicks the "List Files" button, the program retrieves the values entered in
the IP, username, and password fields. It then creates an instance of the FTPClient class from the
Apache Commons library, connects to the server, and attempts to log in with the provided
credentials. If the login is successful, it retrieves a list of files in the current directory and displays
them in a dropdown box. It also appends the file names and other status messages to a text area
called "statusWindowArea". Finally, it logs out and disconnects from the server. Any exceptions that
may occur during the process are caught and printed to the console.
Input:
IP Address – 10.2.0.5
Username – cse19xx
Password – xxxxxxx
Output:
The files in the ftp server login are listed in the output window text area.
Packages Used:
• java.io.*
• org.apache.commons.net.ftp.*
• FTPClient
o FTPClient()
o connect()
o getReplyCode()
o login()
o listFiles()
o logout()
o disconnect()
• FTPReply
o isPositiveCompletion()
• FTPFile
o getName()
Program:
package ftpserverclientby42;
import java.io.*;
import javax.swing.JFileChooser;
import org.apache.commons.net.ftp.*;
import org.apache.commons.net.ftp.FTPClient;
public class FTPClientInterface extends javax.swing.JFrame {
private void listFilesButtonActionPerformed(java.awt.event.ActionEvent evt)
{
String ip = IPField.getText();
String username = usernameField.getText();
String password = new String(passwordField.getPassword());
try {
FTPClient ftpc = new FTPClient();
ftpc.connect(ip);
int status = ftpc.getReplyCode();
if(FTPReply.isPositiveCompletion(status)){
statusWindowArea.append("Connected to " + ip + "\n");
if(ftpc.login(username, password)){
statusWindowArea.append("User " +username+ " logged in
to " +ip+ "\n");
statusWindowArea.append("Current directory is
"+ftpc.printWorkingDirectory()+"\n");
FTPFile[] files = ftpc.listFiles();
dropdownBox.removeAllItems();
for(FTPFile file : files){
dropdownBox.addItem(file.getName());
statusWindowArea.append(">" + file.getName()+
"\n");
}
if(ftpc.logout()){
statusWindowArea.append("User " +username+ " logged
out. \n");
}
ftpc.disconnect();
statusWindowArea.append("Disconnected from " +ip +
"\n");
}
} else {
statusWindowArea.append("Invalid Credentials");
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
Output Images:
PROGRAM - 10 (b)
Program Statement:
Implement a GUI based FTP Client program to download a file.
The code you provided is for a Java Swing based FTP client. The main functionalities are connecting
to an FTP server, logging in, listing files, and downloading a file from the server. The
“listFilesButtonActionPerformed” method is triggered when the "List Files" button is pressed, it
connects to the FTP server using the IP, username and password provided by the user and lists all the
files in the current directory. The “downloadButtonActionPerformed” method is triggered when the
"Download" button is pressed, it allows the user to select a file from the list of files in the current
directory and download it to the local machine.
Input:
IP Address – 10.2.0.5
Username – cse19xx
Password – xxxxxxx
Output:
The files in the ftp server login are listed and download operation is performed for a file.
Packages Used:
• java.io.*
• org.apache.commons.net.ftp.*
• FTPClient
o FTPClient()
o connect()
o getReplyCode()
o login()
o listFiles()
o logout()
o disconnect()
o retrieveFile()
• FTPReply
o isPositiveCompletion()
• FTPFile
o getName()
Program:
package ftpserverclientby42;
import java.io.*;
import javax.swing.JFileChooser;
import org.apache.commons.net.ftp.*;
import org.apache.commons.net.ftp.FTPClient;
public class FTPClientInterface extends javax.swing.JFrame {
private void listFilesButtonActionPerformed(java.awt.event.ActionEvent evt)
{
String ip = IPField.getText();
String username = usernameField.getText();
String password = new String(passwordField.getPassword());
try {
FTPClient ftpc = new FTPClient();
ftpc.connect(ip);
int status = ftpc.getReplyCode();
if(FTPReply.isPositiveCompletion(status)){
statusWindowArea.append("Connected to " + ip + "\n");
if(ftpc.login(username, password)){
statusWindowArea.append("User " +username+ " logged in
to " +ip+ "\n");
statusWindowArea.append("Current directory is
"+ftpc.printWorkingDirectory()+"\n");
FTPFile[] files = ftpc.listFiles();
dropdownBox.removeAllItems();
for(FTPFile file : files){
dropdownBox.addItem(file.getName());
statusWindowArea.append(">" + file.getName()+
"\n");
}
}
} else {
statusWindowArea.append("Invalid Credentials");
}
} catch(Exception e) {
e.printStackTrace();
}
}
private void downloadButtonActionPerformed(java.awt.event.ActionEvent evt)
{
try {
String filename =
(String)dropdownBox.getSelectedItem();
System.out.println(filename);
File fname = new File(filename);
OutputStream os = new BufferedOutputStream(new
FileOutputStream(fname));
if(ftpc.retrieveFile(filename, os))
{
statusWindowArea.append("Succesfully downloaded
\n");
}else{
statusWindowArea.append("Couldn't download\n");
}
os.close();
if(ftpc.logout()){
statusWindowArea.append("User " +username+ " logged
out. \n");
}
ftpc.disconnect();
statusWindowArea.append("Disconnected from " +ip +
"\n");
}
} else {
statusWindowArea.append("Invalid Credentials");
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
Output Images:
PROGRAM - 10 (c)
Program Statement:
Implement a GUI based FTP Client program to upload a file
This code is for a Java Swing Application that implements a basic FTP client interface. The interface
includes a text field for entering the IP address of the FTP server, a text field for entering the
username, a password field for entering the password, a button to list files on the server, a dropdown
box to select a file to download or upload, a button to upload a file, and a button to download a file.
The listFilesButtonActionPerformed method is called when the "list files" button is pressed. It
connects to the FTP server using the IP address, username, and password provided by the user. If the
connection is successful and the credentials are valid, it lists the files on the server and displays them
in the dropdown box.
Input:
IP Address – 10.2.0.5
Username – cse19xx
Password – xxxxxxx
Output:
The files in the ftp server login are listed in the output window text area.
Packages Used:
• java.io.*
• org.apache.commons.net.ftp.*
Classes and Methods Used:
• FTPClient
o FTPClient()
o connect()
o getReplyCode()
o login()
o listFiles()
o logout()
o disconnect()
o storeFile()
• FTPReply
o isPositiveCompletion()
• FTPFile
o getName()
Program:
package ftpserverclientby42;
import java.io.*;
import javax.swing.JFileChooser;
import org.apache.commons.net.ftp.*;
import org.apache.commons.net.ftp.FTPClient;
public class FTPClientInterface extends javax.swing.JFrame {
private void listFilesButtonActionPerformed(java.awt.event.ActionEvent evt)
{
String ip = IPField.getText();
String username = usernameField.getText();
String password = new String(passwordField.getPassword());
try {
FTPClient ftpc = new FTPClient();
ftpc.connect(ip);
int status = ftpc.getReplyCode();
if(FTPReply.isPositiveCompletion(status)){
statusWindowArea.append("Connected to " + ip + "\n");
if(ftpc.login(username, password)){
statusWindowArea.append("User " +username+ " logged in
to " +ip+ "\n");
statusWindowArea.append("Current directory is
"+ftpc.printWorkingDirectory()+"\n");
FTPFile[] files = ftpc.listFiles();
dropdownBox.removeAllItems();
for(FTPFile file : files){
dropdownBox.addItem(file.getName());
statusWindowArea.append(">" + file.getName()+
"\n");
}
}
} else {
statusWindowArea.append("Invalid Credentials");
}
} catch(Exception e) {
e.printStackTrace();
}
}
private void uploadButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String ip = IPField.getText();
String username = usernameField.getText();
String password = new String(passwordField.getPassword());
try {
ftpc = new FTPClient();
ftpc.connect(ip);
int status = ftpc.getReplyCode();
if(FTPReply.isPositiveCompletion(status)){
statusWindowArea.append("Connected to " + ip + "\n");
if(ftpc.login(username, password)){
statusWindowArea.append("User " +username+ " logged in
to " +ip+ "\n");
statusWindowArea.append("Current directory is
"+ftpc.printWorkingDirectory()+"\n");
fileChooser = new JFileChooser();
fileChooser.showOpenDialog(null);
File file = fileChooser.getSelectedFile();
InputStream is = new BufferedInputStream(new
FileInputStream(file));
if(ftpc.storeFile(file.getName(), is)){
statusWindowArea.append("Successfully uploaded\n");
is.close();
} else {
statusWindowArea.append("Couldn't upload\n");
}
} else {
statusWindowArea.append("Invalid Credentials");
}
} else {
statusWindowArea.append("Connection Failed");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Output Images:
PROGRAM – 11
Program Statement:
Implement a GUI/CUI based 3-tier application.
A three-tier application is a specific type of n-tier architecture. In the case of three-tier architecture,
the tiers are as follows:
• Presentation tier (also known as the user interface or the client application): -
The user interaction is managed by the presentation tier, which provides an easy-to-operate
front end. It communicates user requests to the application server and presents the results
to the user.
The business rules are managed by the business tier(also known as the middle tier), which
controls and operates the entire application framework. The business rules are removed
from the client and are executed in the application server. The application server ensures
that the business rules are processed correctly. It also serves as an intermediary between the
client application and database server.
The underlying data is stored and served by the data storage tier, also known as data
persistence. It serves Data whenever the application server sends a request to it.
Our 3-tier application consists of a database server, backend server in this case java, and a frontend
User interface, which in this case is Java Swing Interface. The interface includes a text field for
entering the username, a password field for entering the password, a text field to enter the
fields/columns to be used in the query, a button to list tables in the database, a dropdown box to
select a table to query, and a button to display the contents of table using the select query.
The listTablesBtnActionPerformed method is called when the "list tables" button is pressed. It
connects to the MySQL server and lists the tables in the database on the server and displays them in
the dropdown box.
The displayTableBtnActionPerformed method is called when the "Display Tables" button is pressed. It
connects to the MySQL server and displays the content in the selected table of the dropdown box
with the specified fields (default * ).
Input:
Username – cse19xx
Password – xxxxxxx
Output:
The tables in the database are listed, and their content is displayed.
Packages Used:
• java.sql.*
• Connection
o createStatement()
o close()
• DriverManager
o getConnection()
• Statement
o executeQuery()
• ResultSet
o getMetaData()
o next()
o getString()
• ResultSetMetaData
o getColumnCount()
o getColumnName()
Program:
import java.sql.*;
Connection con;
try{
Class.forName("com.mysql.cj.jdbc.Driver");
connectBtn.setEnabled(false);
disconnectBtn.setEnabled(true);
catch(Exception e){
e.printStackTrace();
try{
con.close();
connectBtn.setEnabled(true);
disconnectBtn.setEnabled(false);
catch(Exception e){
e.printStackTrace();
try{
Statement stmt = con.createStatement();
jComboBox1.removeAllItems();
while(rs.next()){
jTextArea1.append(rs.getString(1)+"\n");
jComboBox1.addItem(rs.getString(1)+"\n");
}catch(Exception e){
e.printStackTrace();
try{
jTextArea1.append("\n");
jTextArea1.append(rsmd.getColumnName(i) + "\t");
jTextArea1.append("\n");
while(rs.next()){
jTextArea1.append(rs.getString(i) + "\t");
jTextArea1.append("\n");
}catch(Exception e){
e.printStackTrace();
Output Images:
PROGRAM – 12
Program Statement:
NFS Case Study – mounting of specified directory from Linux server to Linux client, windows client.
The basic idea behind NFS is that each file server. provides a standardized view of its local file system.
This approach has been adopted for other distributed files systems as well. NFS allows a
heterogeneous collection of processes to run on different operating systems and machines, and share
a common file system.
The model underlying NFS and similar systems is that of a remote file service. In this model, clients are
offered transparent access to a file system that is managed by a remote server. However, clients are
normally unaware of the actual location of files. Instead, they are offered an interface to a file system
that is similar to the interface offered by a conventional local file system. In particular, the client is
offered only an interface containing various file operations, but the server is responsible for
implementing those operations. This model is therefore also referred to as the remote access model.
A client accesses the file system using the system calls provided by its local operating system. However,
the local UNIX file system interface is replaced by an interface to the Virtual File System (VFS), which
by now is a de facto standard for interfacing to different (distributed) file systems.
Procedure:
Linux Server:
• Install linux full-fledged – RHEL (Red hat enterprise linux)
>setup
>mkdir /var/mySharedFolder
>vi /etc/exports
• Mention the shared folder path , client Ip that can mount it and the different permissions by
adding a line at the end file as below
• Then restart the NFS service to apply the changes with the command
• Make a directory
>mkdir myMountFolder
Syntax: -
>mount -t nfs server-IP:folder-path-on-server folder-path-on-client
Ex: -
>mount -t nfs 10.2.0.5:/var/mySharedFolder /myMountFolder
• Now you can access the mounted folder by changing directory to myMountFolder
Windows client-:
• Go to control panel>programs>turn windows features on or off
Windows client-CMD:
• Run CMD as Admin
Syntax:-
>mount -o anon \\server-ip\folder-path\ drive-letter
Ex:-
>mount -o anon \\10.2.0.5\var\mySharedFolder\ K:
>K:
K:>dir
…………..
…………..
• Above address bar, in the computer tab select “Map network drive”
\\10.2.0.5\var\mySharedFolder
• Click finish