Chapter 6
Chapter 6
CLINT-SERVER COMPUTING
Client/Server computing
Client/Server: used to describe a computing model for the development of computerized
systems.
This model is based on the distribution of functions between two types of independent and
autonomous processors: servers and clients.
Client and server processes can reside in the same computer or in different computers
connected by a network.
When Client and Server processes on two or more independent computers on a network,
the Server can provide services for more than one Client.
Cont…
In addition, a client can request services from several servers on the network without
regard to the location or the physical characteristics of the computer in which the
Server process resides.
These days many web pages are not served from static files on the hard drive. Instead,
the server generates them dynamically to meet user requests.
The content may be pulled from a database or generated algorithmically by a program.
In Java, server-side programs are written using servlets or Java Server Pages (JSP).
They can also be written with other languages, such as C and Perl, or other frameworks,
such as ASP and PHP.
Cont…
Client/Server Architecture
The client/Server architecture is based on hardware and software components that interacts
to form a system.
This system includes three main components:
(i) Hardware (client and server).
(iii) Communication middleware. (associated with a network which are used to link
the hardware and software).
cont…
The client is any computer process that requests services from server. The client uses the
services provided by one or more server processors.
The client is also known as the front-end application, reflecting that the end user usually
interacts with the client process.
The server is any computer process providing the services to the client and also supports
multiple and simultaneous clients requests.
The server is also known as back-end application, reflecting the fact that the server
process provides the background services for the client process.
Cont…
The communication middleware is any computer process through which client and
server communicate.
Middleware is used to integrate application programs and other software components in a
distributed environment.
Also known as communication layer, that aids the transmission of data and control
information between Client and Server.
Communication middleware is usually associated with a network.
Cont…
Client
Server
Sometimes on Always on
Initiates a request to the server when Not initiate contact with the clients
interested
Serve services to many clients
E.g., web browser
E.g.,www.dbu.com
Needs to know the server’s address
Needs a fixed address
Cont…
Print Server
This machine manages user access to the shared output devices, such as printers.
Print services can run on a file server or on one or more separate print server machines.
Application Server
This machine manages access to centralized application software; for example, a shared
database.
When the user requests information from the database, the application server processes
the request and returns the result of the process to the user.
Mail Server
This machine manages the flow of electronic mail, messaging, and communication with
mail server systems on large-scale networks.
Cont…
Fax Server
Provides the facility to send and receive the Faxes through a single network connection.
The Fax server can be a workstation with an installed FAX board designed for Fax
Services.
This machine manages flow of fax information to and from the network
Web Server
This machine stores and retrieves Internet (and intranet) data for the enterprise. Some
documents, data, reside on web servers.
Web application provides access to documents and other data.
“Thin” clients typically use a web browser to request those documents.
Cont….
Database Server
Data resides on server, in the form of a SQL database. Database server provides access
to data to clients, in response to SQL requests.
It shares the data residing in a database across a network.
Transaction Servers
The Server provides access to high level functions, and implements efficient transaction
processing.
It shares data and high level functions across a network.
Transaction servers are often used to implement Online Transaction Processing (OLTP)
in high-performance applications.
Web Technology
The Internet and expanded network connectivity established Client/Server models as the
preferred form of distributed computing.
When talking about Client/Server models of network communication using web services
the broadest components of this paradigm become the web browser (functioning as the
client) and web server.
At the most basic level, the process for web communication works as follows:
A computer runs a web browser that allows it to request, communicate and display HTML
documents (web pages).
Web browsers are the software applications that allow users to access and view these web
pages and they run on individual computers.
Cont…
After typing in the URL and pressing return, the request is sent to a server machine that
runs the web server.
The web server is the program that delivers the files that make up web pages.
Every web site or computer that creates a web site requires a web server.
Step1: The user types in a URL or fills out a form or submits a search on a Web page and
clicks the Submit button.
Step 2: The browser sends the user’s query from the browser to the Web server, which
passes it on to a CGI script.
Step 3: The CGI script loads a library that lets it talk to an SQL database server, and it uses
that library to send SQL commands to the database server.
Step 4: The database server executes the SQL commands and sends the request information
to the CGI script.
Step 5: The CGI(common get interface) script generates an HTML document and writes the
HTML document to the Web server.
Step 6: The Web server sends the HTML page back to the remote user.
Sockets
A socket is one endpoint of a two-way communication link between two programs
running on the network.
A socket is a connection to another machine. A server will listen for connections on a
particular port.
From the server side, the input stream is read to get commands from the client and the
output stream is used to write results back to the client.
From the client side, the output stream is used to write commands to the server and the
input stream is used to read the results from the server.
Cont…
A socket consists of
Local socket address: Local IP address and service port number
Remote socket address: Only for established TCP sockets
Protocol: A transport protocol, e.g., TCP or UDP.
Port number is an integer to uniquely identify each server socket on the system.
Name of the system and port number uniquely identify server socket in the network.
Once you established a connection with socket.
You can take Inputstream to read data from socket and Outputstream to write data to
socket.
Cont…
Client Socket :
Socket is a listener through which computer can receive requests and send respond.
The listener of a client system is called socket.
Socket class represent a client socket. A client socket connects to a server socket, which
is created using serversocket calss.
Address of server is specified either by using IP address or the name of the computer.
Server socket:
The listener of server system is called server socket
Create a server socket with the given port number.
A server socket waits for a request to come from clients and process the request.
Functions in socket programming
socket() :create the socket descriptor
bind() :associate the local address
• Returns 0 on success, and -1 if an error occurs
listen() :wait for incoming connections from clients
Returns 0 on success, and -1 on error
accept() :accept incoming connection
Returns descriptor for a new socket for this connection
read(),write() :communicate with client
close() :close the socket descriptor
Cont…
Multithreading
Multitasking:- Executing multiple task at a time is called multitasking.
E.g While typing a program we can download a file, we can listen music.
Types of Multitasking
1. Process based multitasking
2. Thread based multitasking
Process based multitasking:- Executing multiple tasks simultaneous is called process
based multitasking, here each task is a separate independent process.
E.g While typing java program we can listen song and the same time we can download a file
from net, all this task executing simultaneously and there is no relationship between these
tasks.
All task have their own independent address space.
Cont…
Thread based multitasking:- Executing multiple tasks concurrently is called thread
based multitasking, here each task is a separate independent part of a single process.
This type of multitasking is developed at programmatic level
Sequential execution:- means single thread execution
Take more time to complete all method of execution
Concurrent execution:- means multithreading execution
Take less time to complete all method execution
Executing multiple task in “start----suspend-----resume-----end” fashion is called
concurrent execution.
In concurrent execution both tasks are started at different point of time and one task is
paused while other task is executing.
Cont…
Thread:
A thread is a code that can act independently of any other code within an application.
The piece of code is usually started by another code, but once it is started, it runs
independently of the original caller, and controls its own destiny.
A thread is an independent sequential flow of execution
It executes methods in sequence one after one.
Multithreading:
It is the process of creating multiple threading to executing multiple tasks concurrently to
finish their execution in short time by using process ideal time effectively.
In multithreading based programming CPU ideal time is utilized effectively.
Multithreading is light weight because switching between context is fast because each
thread is stored in same address.