design of a wireless communication software between multiple clients and a single server to reduce...
TRANSCRIPT
CHAPTER 1
1.1 INTRODUCTION
There is much excitement about the Internet and the World Wide
Web. The internet ties the information world together. The World
Wide Web makes the Internet easy to use and gives it the flair
and sizzle of multimedia. Organizations see the Internet and the
Web as crucial to their information-systems strategies. Java
provides a number of built-in networking capabilities that make
it easy to develop Internet-based and Web-based applications.
Java can enable programs to search the world for information
and to collaborate with programs running on other computers
internationally, nationally or just within an organization. Java can
enable applets and applications to communicate with one
another (subject to security constraints). (Gregory, 2011, p.92).
server and multiple clients gives a broader design from the
common server and a single client model, which does not have
modern algorithm. Organization are seeking to have easy and
better means of communication between staffs and customers.
1
With this design, people can easily pass information around in a
cheaper and better algorithmic manner.
Here we focus on both sides of the client-server relationship
using Java Programming Language. The client requests that
some action be performed, and the server performs the action
and responds to the clients. The clients will also be able to
establish connection between themselves through the server
itself. Java’s fundamental networking capabilities are declared by
classes and interfaces of package java.net, through which Java
offers stream-based communication that enable applications to
view networking as streams of data. The classes and interfaces of
package java. net also offer packet-based communication for
transmitting individual packets of information commonly used to
transmit audio and video over the Internet.
1.2 Statement of Problem
The problem at hand is how to develop clients and server
software application using Java, where by the clients will be able
to communicate with the server successfully and also establish
connection with themselves to enable easy communication
2
between individuals. Though the clients- server application
software is vastly superior to the monolithic architecture, the
design approach locates the three main development layers in
just two locations (in the client or in the server). (Wiersma, 2013)
According to O’ Brien, (1971, p. 1739) the advantages of the
clients and server communication application include: 1. high
security of transmitted signal. You cannot create connection with
the server if you are not the right person because connections
are pass worded. 2. Low cost of implementation. This design
requires you working without the interest, therefore
communication is established without the interest.
The networking media (media wires) helps in connecting
both the client and server together. These are the straight-
through cable, the cross over cable, the rollover cable and the
twisted pair cables. This media wires are all prone to noise, have
a maximum length of 100m and their signal transmission is not
dynamic but static. All of this has made the client and server
application software superior to that established using media
wire. There is no noticeable noise while using the client and
server communication software (Dr. Okeke, 2011).3
Most of these systems can hang during communication
because of the concern of security. Consequently, in this
application the possibilities are there that this problem can be
killed manually during the design of the clients and server
communication software and it is very easy when you are using
UNIX.
1.3 AIM AND OBJECTIVES
The aim of this project is to develop a wireless communication
software to reduce cost between Server and multiple Clients’
communication with the following objectives;
The creation of a communication software application for
Client / Server and Client to Client communication.
High security of transmitted signal. You cannot create
connection with the server if you are not the right person
because connections are all pass worded.
Low cost of implementation. This design requires you
working without the internet, therefore communication is
established without the internet.
4
1.4 Significance of the study
The significance of this project is as follows:
For better data transfer from the client application to the
server application as well as the Client to Client application.
Better reduction in the cost of setting up a network between
two computers where by one is acting as the client and the
other one the client.
Great speed in connecting the client to the server is
enhanced
Better security features to protect the data transferred
between the server and the client.
1.5 Scope of the study
This project is limited to the design and implementation of a
server and client chatting software at the Department of
Computer Science without the use of cables.
5
CHAPTER 2LITERATURE REVIEW
2.1 Historical Background
The growth of wireless communication in the past few years
means you can stay connected to a network regardless of
whether you are in the neighborhood or across the country.
Mobile communication devices, peer to peer methods, and a
computation-pervaded environment are making it possible for
6
people to organize, communicate with and be aware of their
family, friends and community on a scale never before possible.
The first use of the concept Server and Client programming,
as it is represented in it’s current form came with the 1977
release of the Unix operating system for the DEC VAX compute,
as implemented at the university of Californian, Berkeley. The
‘BSD’ release had two main improvement over the previous PDP
11 implementation of UNIX implemented at Bell Labs (Benatallah,
et al, 2004).
First, the new BSD version supported demand paging
virtual memory that was characteristic of the Vax computer, and
the BSD released supported Ethernet networking hardware that
was gaining increasing popularity in the minicomputer field as
computers began the trend towards becoming communication
devices as well as computational devices.
With the introduction of networking in minicomputers, the
UNIX system call interface was enhanced with the addition of
“sockets”. The addition of sockets created a new way to get a file
descriptor, which could point to an open network connection
7
instead of a file in the file system. The parameter used to create
the socket were the name of the intended host, or hostname, the
domain of the untended host, and the port number, or an integer
which identifies an intended service on the host.
While both the server and client have socket data
structures, the client is distinguished from the server by the way
in which a connection is initiated.
2.2 Recent Advancement in Server And Client Technology
Server and Client application have greatly improved with
the creation of a sub application into computer system by
Microsoft cooperation to perform the process of communicating
with each other. These methods of creating application into
systems have not been able to prove the needed security in
preventing hackers from access information from unexpected
persons. Example of such advancement is the Microsoft Windows
Server—To Client Networking ( Ehigator, 2008).
8
2.2.1. Microsoft Windows Server-to-Client Networking
According to ATC monitor, 2008, Microsoft began its foray
into the OLAP Server business by acquiring the OLAP software
technology from Israeli based Panorama. This Microsoft
Windows Server — TO- Client Networking platform is Microsoft’s
implementation of Server to Client technology. It is part of
Window XP SP2, Window Vista, and Window 7 and is also
available as an add-on for Windows XP SP1. It includes two
technologies that you can use when creating .NET to Server to
Client. Their applications include:
• The Server Name Resolution Protocol (SNRP} which is used
to unpublished, publish and resolve server/client addresses
• The People near Me server, which is used to locate pairs
(currently for Vista and Window 7 only).
2.2.2 Limitation
Although the security feature of the Microsoft Server to
Client application is protective against IP theft the other
limitation are elaborated below:
9
• It does not contain a DNS query in the program( it is
created outside the program)
• Data Encapsulation is thin because of the inability to create
its own network once connection is established.
• ITS class chat client is created with basic visual language.
• Its design is so complex and difficult to use because of the
step involved in connecting to the server.
A DNS query is a good example where using a connection-
oriented service does not make sense. With a DNS query, a
device is trying to resolve a fully qualified domain name to an IP
address. The device sends the single query to a DNS server and
waits for the server’s response. In this process, only two
messages are generated: the clients query and the server’s
response (Wikipedia, 2014).
Since it is built outside the main program it will not be
efficient to properly secure data transmission between the server
and the client. With the Java server and client software the DNS
has been encoded within the program that eliminates the
possibility of an easy means of hacking systems IP address. This
application will only allow the systems name to be accessible but 10
it will hide the IP in a shielded format to reduce the possibility of
hacking.
This application that I have designed have the ability to
create its own network once connection has been established
providing a large encapsulation of data. With Java we can
eliminate and create large encapsulation of data. With Java we
can eliminate and create a network once connection has been
established. Java supports stream socket and Datagram sockets;
stream socket uses TCP (Transmission Control Protocol) for data
transmission whereas datagram socket uses UDP (User
Datagram Protocol).Since TCP can detect lost transmissions and
resubmit them, transmission are lossless and reliable. UDP in
contract cannot guarantee lossless transmissions. Because of
these, stream sockets are used in this
2.3 Network Topology
Network topology defines the structure of the network. It
defines how the computers will be connected between each
others. This type of topology is the logical topology which we are
considering which defines how the media is accessed by the
11
hosts for sending data. The other topology is the physical
topology which is the actual layout of the wire (this is what we
are trying to eliminate). (Robert, 2007)
For two system to communicate they have to be connected
together to form a network. When you are cabling up a computer
and networking devices, various types of topologies can be used.
A topology defines how the devices are connected. For the Client
and Server application I designed its networking structure is a
Peer to peer topology but not a peer to peer network.
2.3.1 Single - Server Topology
Single-server topology is the smallest supported topologies.
In configuration, all client security server components are
installed on a single server. It is ideal for test environments or
for small deployments. Depending on the hardware of the
servers, the single server topology can support up to 3,000
managed computers (Robert, 2011)
The number of managed computers processors, ram, and
hard disk configuration are up to 1,000. Two 2GHZ or faster,32-
12
bit,2G8 integrated drive electronics(IDE) disks with the
operating system, data files, and log files separated.
2.3.2 Two Server Topology
The two server topology separates the distribution
component onto its server. This topology is useful primarily for
organizations that already have an existing WSUS infrastructure.
Server sizing recommendations are similar for this topology as
for the single-server topology.
2.3.3 Three-Server Topology
The three- server topology separates the heavily used
reporting database onto its own server. The management,
collection, and reporting components as well as the collection
database are on a second server, and the distribution component
is installed on a third server. This topology, like the two-server
topology, works well with organizations that have an existing
WSUS infrastructure, because the distribution server is separate
from all other server components. Additionally, the separation of
the reporting database from all other components reduces the
13
load incurred by the management, collection, and reporting
server (Robert, 2011).
2.4 Bandwidth Management for Server - to –Client
Application
With the increasing proliferation of broadband, more and
more users are using Server and client protocols (TCP/IP) to
share very large files, including software, applications. This trend
has exponentially increased traffic flows across a very wide area
network. If you are coping with excessive bandwidth
consumption due to Server/ Client traffic such as Bit Torrent,
EMule, numerous Gnutella clients, Direct Connect, Kazaa, etc.,
conventional rate shaping techniques such as limiting bandwidth
by TCP port number may not do the trick. A more powerful
technique based on application signature identification via
packet inspection may be needed (Bicsi, B., 2002).
Traditional rate shaping techniques may not be sufficient to
control new breeds of applications. For example, Bit Torrent is a
protocol that is typically used by simple desktops to transfer user
Files via broadband connections. However, using Bit Torrent to
14
transfer high volumes of data puts huge pressures on the
broadband operators’ network. Unfortunately, prohibiting Bit
Torrent traffic has become routine for some broadband operators
and is now a key area of contention between users and
broadband operators.
Individualized control that can return double-digit capacity
without spending a dime on additional bandwidth. Through the
combination of iRules and Rate Shaping in Server/Client, you
can:
Ensure that critical applications are not impacted by non—
priority traffic.
Eliminate special purpose Rate Shaping products for
simplified, centralized data management capabilities.
Provide flexible bandwidth limits, bandwidth borrowing, and
data queuing.
Control rate classes based on any data variable
2.4.1 How the Bandwidth is used in the Control of Data
According to D. Fedyk, Ed., P. Ashwood-Smith (April 2012), Bandwidth
is very much important in the transmission of data from the
15
server and client communication. In order to protect the data
signals the code I used is pseudo- random.
• The data signal form any of the client or server occupies a
bandwidth much greater than that which is necessary to
send the information. This results in many benefits, such as
immunity to interference and jamming and a single access
• The bandwidth is spread by means of a code which is
independent of the data. The independence of the code
distinguishes this from standard modulation scheme in
which the data modulation will always spread the spectrum
in definite form.
The receiver either the server or the client synchronizes to
the code to recover the data. The use of an independent
code and synchronous reception allows users to access the
same frequency band at the same time.
There are three essential ways to spread the bandwidth of signal
en the server and client systems this includes:
Frequency hopping: the data signal is rapidly switched
between different frequencies within the hopping
16
bandwidth pseudo- randomly, and the server or client end
will know before hand where to find the signal at any given
time once connection is established.
Time hopping: time is an essential element in data
transmission. In this way the data signal is transmitted in a
short bursts pseudo- randomly, and the receiver knows
before hand when to expect the burst.
Time —Hopping makes access possible by dividing the
channel into non-overlapping timeslots SF. Total assigned
frequency band is Tf and the signal frequency per channel is
Tmono while number of channels is shown below:
SF=T f /T mono {2.1 }
Where SF is no overlapping time slots
T f is the Total frequency assigned
Tmono is the single channel frequency
2.5 Data Flow Control
17
Flow control is designed in the server program to ensure
that the client devices do not send too much information to the
destination, overflowing its receiving buffer space, and causing it
to drop the sent information. The purpose of the flow control is to
ensure the server does not get over run by too much information
sent by the client. It is important to develop programs in the
main program in other to control the flow of data so that
messages sent to both the client end user and the server (Brien,
D., 2014)
2.6 Over View of the Client Server Network
The client server network communication system is
implemented by using java programming language for
application interface and use to detect the network feature and
uses Java serializable interface method to store the message of
the system and important data of the system. And this system
use the Java communication package for detecting Network card
and Network devices and Network ports and other
undocumented devices and software. So this package is called as
documented package and this system can detect USB ports and
devices. E Sun Micro Systems are developing this package for 18
Linux platform and not for Microsoft platform. But this result
includes the system which can detect the USB ports and devices
on Microsoft platform. This package is third party package but it
is an Open source package. The development of socket
programming propagated the transmitted the total development
of client and Server communication (Otey, Michael, 2011).
2.6.1 Sockets Programming in Java a Bit of History
The UNIX input/output (I/O) system follows a paradigm
usually referred to as Open-Read-Write-Close. Before a user
process can perform I/O operations, it calls Open to specify and
obtain permissions for the file or device to be used. Once an
object has been opened, the user process makes one or more
calls to Read or Write data. Read reads data from the object and
transfers it to the user process, while Write transfers data from
the user process to the object. After all transfer operations are
complete, the user process calls close to inform the operating
system that it has finished using that object. When facilities for
Inter Process Communication (IPC) and networking were added
to UNIX, the idea was to make the interface to IPC similar to that
of file I/O. In UNIX, a process has a set of I/O descriptors that 19
one reads from and writes to. These descriptors may refer to
files, devices, or communication channels (sockets). The lifetime
of a descriptor is made up of three phases: creation (open
socket), reading and mg (receive and (receive send to socket),
and destruction (close socket).
The IPC interface in I3SD4ike versions of UNIX is
implemented as a over the network TCP and UDP protocols.
Message destinations are specified as socket addresses; each
socket address is a communication identifier that consists of a
port number and an internet address.
The IPC operations are based on socket pairs, one
belonging to a communication process. IPC is done by
exchanging some data through transmitting that data in a
message between a socket in one process and another socket in
another process. When messages are sent, the messages are
queued at the sending socket until the underlying network
protocol has transmitted them. When they arrive, the messages
are queued at the receiving socket until the receiving process
makes the necessary calls to receive them.
20
2.6.2 Datagram Communication
This communication protocols that is used for socket
programming:
datagram communication and stream communication. The
datagram communication protocol, known as UDP (user
datagram protocol), is a connectionless protocol, meaning that
each time you send datagram, you also need to send the local
socket descriptor and the receiving socket’s address. As you can
tell, additional data must be sent each time a communication is
made.
2.6.3 Stream Communication
The stream communication protocol is known as TCP
(transfer contro1 protocol). Unlike UDP, TCP is a connection-
oriented protocol. In order to do communication over the TCP
protocol, a connection must first be established between the pair
of sockets. While one of the sockets listens for a connection
request (server), the other asks for a connection (client). Once
two sockets have been connected, they can be used to transmit
21
data in both (or either one the) directions. This was the protocol I
used in the design of the server and client application.
2.6.4 Significance of using The TCP To UDP
UDP is an unreliable protocol — there is no guarantee that
the diagrams you have sent will be received in the same order by
the receiving socket. On the other hand, TCP is a reliable
protocol; it is guaranteed that the packets you send will be
received in the order in which they were sent. It is very much
important to program in socket because without the soccket
program will cannot establish a connection between the server
and the Client.
2.7 Peer to Peer Networking and Server to Client
Networking
Peer - to - peer networking is an alternative approach to
network communication. The P2P differs from the “standard”
approach to network communication and networked application
today.
The peer - to - peer approach is completely different from
either the scaling up or scaling out approach. With P2P, instead 22
of focusing on and attempting to streamline the communication
between the server and its clients, you instead look at ways in
which clients can communicate with each other.
You could use P2P technology to prevent web server
collapse.
Instead of sending the file directly from the server to all the
clients, you send the file to just a few clients. A few of the
remaining clients then download the file from the clients that
already have it, a few more clients download it from those second
— level clients, and so. In fact, this process is made even faster
by splitting the file into chunks and dividing these chunks among
clients, some of whom download it directly from the server and
some whom download chunks from other clients. (Hong, K.,
2014).
Whereas the design of my own client and server network
communication software will allow a connection to be established
without using a web browser by encoding the IP to be channeled
as the computer name. It is definitely different from the peer to
peer network
23
2.8 Expected Contribution of My Design
My design simple deals with the basic aspect of the Server
and client application. The use of Java in the design of the client
server creates a better security features in the application. We
created buffered streams I/O to provide efficient higher level
communication facilities over streams. We then setup our simple
user interface of the Text Area and Text field Input, which are
easy to comprehend. This design of a wireless communication
server and client application is expected to be setup at the
Department of Computer Science to provide faster means of
sending and receiving messages between an individual by using
their computer systems. The design topology is designed as a
peer to peer topology which is different from the peer to peer
network. Its simplicity is as a result of Java is better to that
programmed in other programming languages such as C and C+
+.
24
CHAPTER 3
ANALYSIS AND DESIGN
The design is made up of software application which follows
a Sequence of processes using Java programming language.
Networking is tightly integrated in Java. Socket-based
Communication is provided which enables programs to
communicate through designated sockets. Sockets are the
endpoints of logical connections between the client/server and
can be used to send and receive data. Java treats socket
communications much as it treats I/O operations; thus programs
can read from or write to sockets as easily as they can read from
or write to files.
Network programming usually involves a server and one or
more clients. The client sends requests to the server, and the
server responds to the requests. The client begins by attempting
to establish a connection to the server. The server can accept or
deny the connection. Once a connection is established, the client
and the server communicate through sockets. The server must
25
be running when a client starts. The server waits for a
connection request from a client.
3.1 Methodology
The project is designed with the use of java programming
language which is a high level language (Net Beans platform was
used) and applied codes. Server was built using Java including
the Client application. Java tools enable the interface to be
created.
It consists of a software application that is install on a
computer system (laptop or desktop computer).The client server
network communication system is implemented by using java
programming language for application interface and use to
detect the network feature and uses java serializable interface
method to store the message of the system and important data of
the system. And this system use the java communication package
for detecting network card and network devices and network
ports and software. Java programmed server and client
communication application includes the system which can detect
devices on Microsoft platform.
26
SERVER INTERFACE CLINT INTERFACE
SERVER CODE CLIENT CODE
SERVER SOCKET CLIENT SOCKET
NETWORK
The basic design of a Client/Client and Server is embedded
in the Java aspect called the Servlet. It has the inlet door and the
outlet door. The inlet door is where the code to create the
connections is embedded while the outlet door contains interface
for streaming connections between client and the server itself.
The design approach simply entail following a sequence of steps
by first using the java creating tool in shaping the interface from
which all the various communication activities will take place.
FIGURE 3.1. BLOCK DIAGRAM OF THE SERVER AND
CLIENT
This design follow a sequence as indicated in Figure 3. 1
above. The class chat client is first of all designed to implements
the chat client. This is the client interface which involves setting
27
up a basic interface to handle user interface, user interaction
and receiving messages. The chat client class extends frame is
also designed in e client interface which is typical for a graphical
application. The code section which is very complex and tedious
is then constructed which involved the use of Java constructor.
This Java ode constructor takes three parameters: a title for
Window, an input stream and an Output stream to perform the
basic setup of e GUI, the run () method which receives messages
from the server, the handle event () method handles user
interaction and the am () method which performs the initial
network connection.
3.1.1 Using the Code
The design consists of five main parts, which are:
Server GUI
Server Class
Client GUI
Client GUI2
Client Class
Comm C Class
28
I made this separation for the sake of reusability. Server
application is a console application.
3.1.2 Server Application and Sockets
To establish a server, you need to create a server
application and socket. The server application design I used is
made with Java. Attach the server socket to a port, which is
where the server listens for connections. The port identifies the
TCP service on the socket. Port numbers range from 0 to 65536,
but port numbers 0 to 1024 are reserved for privileged services.
For instance, the email server run on port 25, and the Web
server usually run on port 80.
public static void main (String[] args) {
// start server on port 1500 unless a PortNumber is specified
int portNumber = 1500;
switch (args.length) {
case 1:
try { portNumber = Integer.parseInt(args[0]);}
catch (Exception e) { System.out.println("Invalid port number.");
System.out.println("Usage is: > java Server [portNumber]");
return;}
29
case 0:
break;
default:
System.out.println("Usage is: > java Server [portNumber]");
return;}
3.1.3 Client Application and Socket
After I created the server socket, I used the statement
below for the server in other for the server to listen for
connection:
Socket socket = serverSocket. Accept ();
This statement waits until the client connects to the server
socket. The client issues the following statement to request a
connection to server
Socket socket = new Socket (server computer name, port);
This above statement opens a socket so that the client
application program can communicate with the server. Server
computer name the server’s host name. The following statement
creates a server socket at port 1500 on the client computer to
connect to the host computer name:
30
Start to Lunchserver
START ACTION
CHOOSEMENU
NO YES
Socket socket new Socket (“computer name”, 1500)
At this point the JVM asks the DNS to translate the host
computer name into an IP address.
31
FIGURE 3.2 FLOW CHART OF SERVER AND CLIENT
3.1.4 Data Transmission through Socket
After the development of the Client and Server socket, the
server accepts the connection, communication between server
and client is conducted the same as for I/O streams. The
32
statements needed to create the streams and to exchange data
between them are shown in Figure 3.3
Client (String server, int port, String username) {// which calls the common constructor with the GUI
set to nullthis (server, port, username, null);
}
/* * Constructor call when used from a GUI * in console mode the ClientGUI parameter is null */Client (String server, int port, String username,
ClientGUI cg) {this.server = server;this.port = port;this.username = username;// save if we are in GUI mode or notthis.cg = cg;
}
3.1.5 The main Program Code
We have already shown you how to create the java
interface, the socket. Therefore connection to be establish, we
have to use the various code indicated below:
33
• Server Creates Service
ServerSocket servsock = new ServerSocket (IP >>#
computer name);
/ / create a new service at a port while (true) {
/ / wait for the client connection
Socket sock=servsock.accept (); / / Listen
// Blocks until a client connects.
/ / handle connection
• The client will respond to be above code in this way
shown below:
Socket sock = new Socket (“channel”, 1500);/ / connect to the servsock.accept.// Get I/O streams from the socketin = new BufferedReader (new InputStreamReader (sock.getlnputStream 0));out = new PrintStream (sock.getOutputStream ); String fromServer = in.readLine 0; /1 Get initial string String reply = ….out.println (reply); out.flush 0;
• The server have to respond again to the above code
while (true){// wait for the client connection Socketsock= servsock. accept 0;/ / Listen
34
/ / Blocks until a client connects.
PrintStream out = new PrintStream( sock.getOutputStream0);BufferedReader in = new BufferedReader new InputStreamReader (sock.getlnputStream 0 ));
/ / Send our initial message
String initial =. . ;#<> jump txt import...import java.net.ServerSocket;import java.net.Socket;import java.io.IOException;
class ChatServer {private static mt port = 1500; /* port the server listens on* / public static void main (String[] args) {
ServerSocket server = null;Try {
server = new ServerSocket(port); / start listening on the
port */} catch (TOException e) {
System.err.println (”Could not listen on port:” + port);System. err. println(e);System. exit( 1);}
Socket client = null;try{
client = server.accept} catch (lOException e) {
System. err. println (”Accept failed.”);System .err. println(e);System.exit( 1); out.println (initial); out.flush();
3.2 Design Analysis
35
To use this application I will first of all start to lunch the
server. When the server is start up, the system creates a server
socket. There are two potions, first is to detect the serial port
and another computer name. This system supposes to detect that
USB device bid port, hardware port and software ports. Some
software is used on server, so the system shows which ports are
used by that software and device. After creating a new socket,
the servers check client’s IP address which is then directed to its
computer name. And also check which client is on network. If the
client is on network, request to client and decide should permit
or not.
The server provides a service by listening on a port, the
client connects to the port at the server this will then creates a
socket and in turn create a new service at the port and wait for a
client connection. When connection is not established on time, I
created a block in the code to initiate until a client connects.
3.3 Creating Fault Management
In security management system design, the system will
check clients and if the client is a valid user of the system, the
36
server will allow to enter the client and if invalid user will
connect. The system cannot accept and resend to the client that
the user is invalid and all of these messages are kept in the Java
in built semi database for this server and client design.
Moreover, there is the user management function to disable
or enable the user account in this system. If the disable user will
connect from client to server, this system will send the message
to the client that the client is connecting the server with the
disable server.
CHAPTER 4
IMPLEMENTATION
I have put a label and a button at the top of the form to act
as a title bar. An event for the label to move the window as
expected from the original title bar. It also includes an anchor, so
when the main window is resized they arrange themselves in
accordance with the new situation.
37
If you click the button “X”, the client logs off the server and
will be closed with an indication in the server notifying us that a
particular Client application have Logout. If you click log off a
message box shows up also.
4.1 Running a Test on the Design
The first thing to do is install the server and clients software
on your laptop computer or desktop. Open the software; make
sure you are using window 8 or window SP2.
Login into the server application by clicking on the Start
button, it then display a statement in the Events log with the
time of Login saying “Server waiting for Clients on port 1500”
because we use a port number of 1500 both for server and
clients.
Put your name provided by yourself on the Client side
before you Login but by default it is “Anonymous”
Input the computer that you want to connect and click on
the connect button. Once it has connected it can also be
instantaneously be disconnected.
38
Fig. 4.1: Server Application showing port Number, start and event Log
39
Once I click on the start button above it will then show
another page with the word “Connection accepted
localhost/127.0.0.1:1500” that is it is trying to establish
connection with the client. Remember that the server is set up to
listen at a given port. The server waits and does nothing until a
client attempts to connect that port. If everything goes fine, the
connection is successful both the server and client have an
instance of the Socket class. From each instance of this class, an
input stream and an output stream can be obtained, and all
communication is done via these earns. The movement of the bar
at the bottom shows that it is trying to establish connection with
the computer am about to connect.
From the above the server application is trying to connect
the client by using the stream through the socket I created
earlier. Once it has connected it will change its window in this
format shown below:
The server has already been connected to the client and
sends the message “HELLO” to the client. The client responds to
the server in the steps provided.
40
The clients establish the conversation when he receives the
message HELLO” and send the message back to the server
through the socket at which he receives the message. This is how
a connection is established. Messages are delivered through the
text bar in the program by the use of java.
INSTALLATION SYSTEM REQUIREMENTS
Installation of the software is very easy. All you need is a laptop
or desktop computer with a window 8, run the application after
installation.
CHAPTER 5
41
SUMMARY, CONCLUSION AND RECOMMENDATION
5.1 SUMMARY
Network programming usually involves a server and one or more
clients. The client sends requests to the server, and the server
responds to the requests. The client begins by attempting to
establish a connection to the server. The server can accept or
deny the connection. Once a connection is established, the client
and the server communicate through sockets. The server must
be running when a client starts. The server waits for a
connection request from a client. The client server network
communication system is implemented by using java
programming language for application interface and use to
detect the network feature and uses java serializable interface
method to store the message of the system and important data of
the system. And this system use the java communication package
for detecting network card and network devices and network
ports and software. Java programmed server and client
communication application includes the system which can detect
devices on Microsoft platform.
42
5.2 Recommendation
Java.Net really facilitates communication between remote
application most especially in the design of the server and client
chatting application. Server and client chatting application which
I designed will greatly reduce the problem of theft and provide
an easy process of moving packet of data between the server and
the client. It can also send data from system without connecting
to the internet since it will have to rip off the IP of the system
into embedded code and gives an output of system name.
This in turn helps to prevent easy accessibility of the system
hardware rid provide a difficult means to determine where the
message is coming from. Economically it is also very feasible to
establish such network in the Department of Computer Science.
What I have to do is to install the software in my laptop or
desktop, then establish a connection with anybody with in the
Department provided their system have the software install in it
can simply use it. With this method no unauthorized person can
monitor my conversation in any way or form.
43
To the best of my knowledge if this software is install in a
system design to aid communication between two system, it will
communication between system in a Local Area Network.
5.2 Conclusion
In this design of a client server network implementation
system, the server can Listen all of the requests of the client and
response to the client. And this system can connect a client at a
giving time and the server listens socket whenever a connection
is established. The introduction of new technology can help
broaden the aspect of data and information transfer to boast
communication as such individual can see the needed benefits to
apply this method to a greater height.
My experience in this type of design is its usability to help
in reducing cost of communication and ease the stress in the use
of media wires in packet data transferring process. The world
today is propelled by changes in the method of designing
portable systems which are security friendly since the rise and
growth of hackers into computer system through systems IP
cannot be over emphasized. Reasonable advancement are been
44
undertaken to boast system security and information passage
like the Microsoft window server client Sock-Direct application.
REFERENCES
1. Dustdar, S.; Schreiner, W. (2005). "A survey on web
services composition". International Journal of Web and
Grid Services 1: 1. doi:10.1504/IJWGS.2005.007545.
45
2. Benatallah, B.; Casati, F.; Toumani, F. (2004). "Web
service conversation modeling: A cornerstone for e-
business automation". IEEE Internet Computing 8: 46.
doi:10.1109/MIC.2004.1260703.
3. Shapiro, Elmer B. (March 1969). Network Timetable.
IETF. RFC 4. Retrieved 30 November 2013.
4. Upadhyaya, B; Azimov, F; Doan, T.T; Choi, Eunmi; Kim,
Sangbum; Kim, Pilsung (2008). Sch. of Bus. IT, Kookmin
Univ., Seoul. "Distributed File System: Efficiency
Experiments for Data Access and Communication".
Networked Computing and Advanced Information
Management, 2008. NCM '08. Fourth International
Conference on (Volume: 2): 400–405.
doi:10.1109/NCM.2008.164. Upadhyaya. Lay summary.
5. Angabini, A; Yazdani, N; Mundt, T; Hassani, F (2011). Sch.
of Electr. & Comput. Eng., Univ. of Tehran, Tehran, Iran.
"Suitability of Cloud Computing for Scientific Data
Analyzing Applications; An Empirical Study". P2P,
Parallel, Grid, Cloud and Internet Computing (3PGCIC),
46
2011 International Conference on: 193–199.
doi:10.1109/3PGCIC.2011.37. Angabini. Lay summary.
6. Andrew Cunningham (July 29, 2012). "Server, simplified:
A power user's guide to OS X Server". Ars Technica.
Retrieved July 31, 2015.
7. Redmond, Tony (31 March 1997). "Microsoft Exchange
Server 5.0 Smoothes the Rough Edges". Windows IT
Pro. Penton.
8. Heaton, Alex (2007-05-18). "On 64-bit and Windows
Client". Windows Vista Team Blog. Retrieved 2015-11-21
APPENDIX
1. SERVER GUI
package application;
import java.awt.*;import java.awt.event.*;
47
import javax.swing.*;
/* * The server as a GUI */public class ServerGUI extends JFrame implements ActionListener, WindowListener {
private static final long serialVersionUID = 1L;// the stop and start buttonsprivate JButton stopStart;// JTextArea for the chat room and the eventsprivate JTextArea chat, event;// The port numberprivate JTextField tPortNumber;// my serverprivate Server server;
// server constructor that receive the port to listen to for connection as parameter
ServerGUI(int port) {super("Chat Server");server = null;// in the NorthPanel the PortNumber the Start and
Stop buttonsJPanel north = new JPanel();north.add(new JLabel("Port number: "));tPortNumber = new JTextField(" " + port);north.add(tPortNumber);// to stop or start the server, we start with "Start"stopStart = new JButton("Start");stopStart.addActionListener(this);north.add(stopStart);add(north, BorderLayout.NORTH);
// the event and chat roomJPanel center = new JPanel(new GridLayout(2,1));chat = new JTextArea(80,80);chat.setEditable(false);
48
appendRoom("Chat room.\n");center.add(new JScrollPane(chat));event = new JTextArea(80,80);event.setEditable(false);appendEvent("Events log.\n");center.add(new JScrollPane(event));add(center);
// need to be informed when the user click the close button on the frame
addWindowListener(this);setSize(400, 600);setVisible(true);
}
// append message to the two JTextArea// position at the endvoid appendRoom(String str) {
chat.append(str);chat.setCaretPosition(chat.getText().length() - 1);
}void appendEvent(String str) {
event.append(str);event.setCaretPosition(chat.getText().length() -
1);
}
// start or stop where clickedpublic void actionPerformed(ActionEvent e) {
// if running we have to stopif(server != null) {
server.stop();server = null;tPortNumber.setEditable(true);stopStart.setText("Start");return;
} // OK start the server
int port;
49
try {port =
Integer.parseInt(tPortNumber.getText().trim());}catch(Exception er) {
appendEvent("Invalid port number");return;
}// ceate a new Serverserver = new Server(port, this);// and start it as a threadnew ServerRunning().start();stopStart.setText("Stop");tPortNumber.setEditable(false);
}
// entry point to start the Serverpublic static void main(String[] arg) {
// start server default port 1500new ServerGUI(1500);
}
/* * If the user click the X button to close the application * I need to close the connection with the server to free
the port */public void windowClosing(WindowEvent e) {
// if my Server existif(server != null) {
try {server.stop(); // ask the
server to close the conection}catch(Exception eClose) {}server = null;
}// dispose the framedispose();
50
System.exit(0);}// I can ignore the other WindowListener methodpublic void windowClosed(WindowEvent e) {}public void windowOpened(WindowEvent e) {}public void windowIconified(WindowEvent e) {}public void windowDeiconified(WindowEvent e) {}public void windowActivated(WindowEvent e) {}public void windowDeactivated(WindowEvent e) {}
/* * A thread to run the Server */class ServerRunning extends Thread {
public void run() {server.start(); // should execute until if
fails// the server failedstopStart.setText("Start");tPortNumber.setEditable(true);appendEvent("Server crashed\n");server = null;
}}
}
2. CLIENT GUIpackage application;
import java.awt.*;import java.awt.event.*;import javax.swing.*;
/* Project was designed by KC * The Client with its GUI */public class ClientGUI extends JFrame implements ActionListener {
51
private static final long serialVersionUID = 1L;// will first hold "Username:", later on "Enter message"private JLabel label;// to hold the Username and later on the messagesprivate JTextField tf;// to hold the server address an the port numberprivate JTextField tfServer, tfPort;// to Logout and get the list of the usersprivate JButton login, logout, whoIsIn;// for the chat roomprivate JTextArea ta;// if it is for connectionprivate boolean connected;// the Client objectprivate Client client;// the default port numberprivate int defaultPort;private String defaultHost;
// Constructor connection receiving a socket numberClientGUI(String host, int port) {
super("Chat Client");defaultPort = port;defaultHost = host;
// The NorthPanel with:JPanel northPanel = new JPanel(new
GridLayout(3,1));// the server name anmd the port numberJPanel serverAndPort = new JPanel(new
GridLayout(1,5, 1, 3));// the two JTextField with default value for server
address and port numbertfServer = new JTextField(host);tfPort = new JTextField("" + port);
tfPort.setHorizontalAlignment(SwingConstants.RIGHT);
52
serverAndPort.add(new JLabel("Server Address: "));
serverAndPort.add(tfServer);serverAndPort.add(new JLabel("Port Number: "));serverAndPort.add(tfPort);serverAndPort.add(new JLabel(""));// adds the Server an port field to the GUInorthPanel.add(serverAndPort);
// the Label and the TextFieldlabel = new JLabel("Enter your username below",
SwingConstants.CENTER);northPanel.add(label);tf = new JTextField("Anonymous");tf.setBackground(Color.WHITE);northPanel.add(tf);add(northPanel, BorderLayout.NORTH);
// The CenterPanel which is the chat roomta = new JTextArea("Welcome to the Chat room\
n", 80, 80);JPanel centerPanel = new JPanel(new
GridLayout(1,1));centerPanel.add(new JScrollPane(ta));ta.setEditable(false);add(centerPanel, BorderLayout.CENTER);
// the 3 buttonslogin = new JButton("Login");login.addActionListener(this);logout = new JButton("Logout");logout.addActionListener(this);logout.setEnabled(false); // you have to login
before being able to logoutwhoIsIn = new JButton("Who is in");whoIsIn.addActionListener(this);whoIsIn.setEnabled(false); // you have to
login before being able to Who is in
53
JPanel southPanel = new JPanel();southPanel.add(login);southPanel.add(logout);southPanel.add(whoIsIn);add(southPanel, BorderLayout.SOUTH);
setDefaultCloseOperation(EXIT_ON_CLOSE);setSize(600, 600);setVisible(true);tf.requestFocus();
}
// called by the Client to append text in the TextArea void append(String str) {
ta.append(str);ta.setCaretPosition(ta.getText().length() - 1);
}// called by the GUI is the connection failed// we reset our buttons, label, textfieldvoid connectionFailed() {
login.setEnabled(true);logout.setEnabled(false);whoIsIn.setEnabled(false);label.setText("Enter your username below");tf.setText("Anonymous");// reset port number and host name as a
construction timetfPort.setText("" + defaultPort);tfServer.setText(defaultHost);// let the user change themtfServer.setEditable(false);tfPort.setEditable(false);// don't react to a <CR> after the usernametf.removeActionListener(this);connected = false;
}
/** Button or JTextField clicked
54
*/public void actionPerformed(ActionEvent e) {
Object o = e.getSource();// if it is the Logout buttonif(o == logout) {
client.sendMessage(new ChatMessage(ChatMessage.LOGOUT, ""));
return;}// if it the who is in buttonif(o == whoIsIn) {
client.sendMessage(new ChatMessage(ChatMessage.WHOISIN, ""));
return;}
// ok it is coming from the JTextFieldif(connected) {
// just have to send the messageclient.sendMessage(new
ChatMessage(ChatMessage.MESSAGE, tf.getText()));
tf.setText("");return;
}
if(o == login) {// ok it is a connection requestString username = tf.getText().trim();// empty username ignore itif(username.length() == 0)
return;// empty serverAddress ignore itString server = tfServer.getText().trim();if(server.length() == 0)
return;// empty or invalid port numer, ignore itString portNumber = tfPort.getText().trim();
55
if(portNumber.length() == 0)return;
int port = 0;try {
port = Integer.parseInt(portNumber);}catch(Exception en) {
return; // nothing I can do if port number is not valid
}
// try creating a new Client with GUIclient = new Client(server, port, username,
this);// test if we can start the Clientif(!client.start())
return;tf.setText("");label.setText("Enter your message below");connected = true;
// disable login buttonlogin.setEnabled(false);// enable the 2 buttonslogout.setEnabled(true);whoIsIn.setEnabled(true);// disable the Server and Port JTextFieldtfServer.setEditable(false);tfPort.setEditable(false);// Action listener for when the user enter a
messagetf.addActionListener(this);
}
}
// to start the whole thing the serverpublic static void main(String[] args) {
new ClientGUI("localhost", 1500);}
56
}
57