You are on page 1of 26

25/08/2011

Anja Christin Kaiser First Semester 2011/2012 Ndejje University

25/08/2011

Client Server Programming for Applications

Content
Client-Server Architecture Peer-to-Peer Architecture (P2P) Pipe-and-Filter Architecture Event Driven Programming Application Layers Open Systems Interconnection (OSI) Model TCP/IP Internet Model

25/08/2011

Client Server Programming for Applications

25/08/2011

Client-Server Architecture
Server Client request Internet responds

The Client asks for a service from the Server. The Server sends back the responds to the client.

25/08/2011

Client Server Programming for Applications

Client-Server Architecture
One part acts as the Server and the other as Client The Server programs starts and provides first some services to connect via a communication channel The Client program asks for services from the Server More than one Client can communicate with the same Server at the same time Clients are mostly browser (Internet Explorer, Firefox, Netscape) Browsers interact with the Server using protocols (a set of instructions) Protocols define the right transfer of data requested by a browser and provide by a Server Protocols are for example HTTP, FTP, SMTP, et.
25/08/2011 Client Server Programming for Applications 4

25/08/2011

Client-Server Architecture
The ideal Client-Server system is independent of the used operating system Client-Server systems can grow or shrink Horizontally: by adding/removing Clients Vertically: by larger/faster Servers or Multi-Servers

25/08/2011

Client Server Programming for Applications

Client-Server Architecture
Centralized Systems
A host computer (mainframe) is responsible for all processes like input, output, data storage and retrieval Clients can be on the same or separate machines Requests are send over a network or local Used in the past (1970s)

Distributed Systems
A number of computers (PCs, workstations) are responsible for all processes Distributed physically Connected through a network Used nowadays

Cooperative Systems
Like distributed but resources are shared transparent for the users
25/08/2011 Client Server Programming for Applications 6

25/08/2011

Client-Server Architecture
Centralized Systems
Printer Client Program

Clients
File Client Program

Mail Server Program File Server Program Printer Server Program


25/08/2011

Internet
Connection

General Server

Client Server Programming for Applications

Client-Server Architecture
Distributed Systems
Printer Client Program

Clients
File Client Program

Mail Server

Mail Server Program

File Server

File Server Program

Printer Server Program

Print Server

Internet
Connection

25/08/2011

Client Server Programming for Applications

25/08/2011

Client-Server Architecture
Advantages of Distributed Systems The work load is distributed on different machines low cost increase of performance Remote access for some services Distributing data minimize loss Easier to implement due to the separation of Client and Server functions Disadvantage Centralized data increase the reliability
25/08/2011 Client Server Programming for Applications 9

Client-Server Architecture
Example The Server starts The Server waits (listen) for the Clients Client starts running Clients performs some operations (for example connecting to the Server) The Server accepts the connection (if willing) The Client sends a request to the Server The Server waits for the request from the Client The Server does the necessary actions The Server responds to the Client This interaction can be continued until one of them shuts down
25/08/2011 Client Server Programming for Applications 10

25/08/2011

Client-Server Architecture
:Server listen connect accept connection send request responds close connection :Client

25/08/2011

Client Server Programming for Applications

11

Client-Server Architecture
Example 2: The WWW The Client is a Web Browser (for example Internet Explorer, Firefox, Opera) A User starts the Web Browser User asks for display web contents The Server is a Web Server (for example Apache Web Server, IIS) The Server listens to incoming requests The Server provides services for the Client (displaying web content) The Server runs infinitely Client terminates when service is complete
25/08/2011 Client Server Programming for Applications 12

25/08/2011

Client-Server Architecture
Model 1: Static Web-Pages
Static Web-Pages do not change until they are modified by their developer
Displays the content of the file Request for a Web Page

Locates the file Server and sends it back

25/08/2011

Client Server Programming for Applications

13

Client-Server Architecture
Model 1: Static Web-Pages Browser takes the URL and embeds it inside a HTTP request Browser sends the HTTP request to the Server Server receives the HTTP request and finds the requested HTML file Server sends back the file and closes the connection Browser interprets the HTML command Browser displays the page content and invokes helper applications (like xview, audio, etc.)

25/08/2011

Client Server Programming for Applications

14

25/08/2011

Client-Server Architecture
Model 2: Dynamic Web-Pages
More work for the Server Requests are for example searches Content of the dynamic web pages depends on the request For example CGI programs
Displays the data Requests for a Web Page

Server Locates the program that processes the request and sends the data to the Server; Server sends back the data to the Browser
25/08/2011 Client Server Programming for Applications 15

Client-Server Architecture
Model 2: Dynamic Web-Pages Browser collects the data and specifies a POST method Server receives the request and searches for the POST method Server starts the CGI program The CGI program reads the environment variables, receives the message body, does some work (database access, etc.) and returns back the result via output pipe Server sends back the result to the Web Browser

25/08/2011

Client Server Programming for Applications

16

25/08/2011

Client-Server Architecture
Model 3: Server Side Scripting Dynamic response due to Server side technologies Easier to maintain web pages Mostly Server side code is embedded in HTML documents Code not visible for Clients Examples
Active Server Pages (ASP) Hypertext Pre-processor (PHP) Java Server Pages (JSP) Server Side Includes (SSI) Java Applets
Displays the file

Requests for a Web Page

Server Locates the file; Execute the embedded scripts; Server sends back the final formatted file to the browser

25/08/2011

Client Server Programming for Applications

17

Client-Server Architecture
Model 3: Server Side Scripting Example: Java Applet Browser requests for a Java Applet Browser initiates a separate network connection to down load the Java Applet in the Web Page Server calls and sends the Java Applet Browser loads the Java Applet into the Client and executes it Afterwards it deletes the Java Applet

25/08/2011

Client Server Programming for Applications

18

25/08/2011

Peer-to-Peer Architecture (P2P)


P2P is a system in which each participant (peer) can act as Client and Server for all other programs P2p is therefore a distributed application architecture The tasks are shared between the peers Each peer has the same rights; they are equal Each peer makes a part of the resources (processing power, disk storage, network bandwidth) These resources are directly available to other network participants They form a connection between each node for sharing information and files Example: Napster (as file sharing system; music), Skype, VoIP, Instant Messaging (Yahoo Messenger)
25/08/2011 Client Server Programming for Applications 19

Peer-to-Peer Architecture (P2P)

P2P without central based Server


25/08/2011 Client Server Programming for Applications 20

10

25/08/2011

Peer-to-Peer Architecture (P2P)


Classification Unstructured Pure No central Server; roles of Clients and Servers are equal Hybrid Some functions are implemented as Client-Server and others as P2P Provide a central Server which keeps peer information/sends those information on request For example: A Client contacts the Server to receive the address of another Client. Than he starts a new session with this Client
25/08/2011 Client Server Programming for Applications 21

Peer-to-Peer Architecture (P2P)


Centralized P2P Central Server used for indexing function and loading the whole system Connection are not defined by an algorithm Structured Peers (and resources) organized according to specific criteria and algorithms Use distributed hash tables

25/08/2011

Client Server Programming for Applications

22

11

25/08/2011

Peer-to-Peer Architecture (P2P)


Advantages Shared resource like bandwidth, capacity, storage space increase the total power of the system Decentralization increase robustness (no single point of failure) Low cost High availability due to large numbers of resources Increased network connectivity Disadvantages Unsecure code can infect the whole network system (viruses, malware) reduced by security and file verification mechanisms Heavy bandwidth because of ongoing file transfer
25/08/2011 Client Server Programming for Applications 23

Client-Server vs. P2P


Advantages of Client Server Architecture Easier to maintain Server can repair, upgrades without affecting the Client Security Data are stored on the server Server controls the access Only permitted clients will get access Administration Controls the flow Disadvantage: Network traffic/availability Single point of failure (Server)
25/08/2011 Client Server Programming for Applications 24

12

25/08/2011

Pipe-and-Filter Architecture
Pipe-and-Filter Architecture consists of arbitrary number of components An event starts a sequence of processing steps Each step performs a specific function The components (filter) transforming/filtering the data Several filter working at the same time Each filter can have any number of input and output pipes Filters can run as different threads or on different machines The data are passed to other components using pipes The pipes are the connectors Each pipe has a certain role in the filter process
25/08/2011 Client Server Programming for Applications 25

Pipe-and-Filter Architecture
Pipes are usually a data buffer to store the data and it should be possible to add and remove pipes at runtime on each filter The data source can be a text file, a keyboard input or a consecutive data input The destination (sink) can be a file, database or a computer screen Simple architecture Examples UNIX programs Compiler; filtering, parsing, analysis and generating program code
25/08/2011 Client Server Programming for Applications 26

13

25/08/2011

Pipe-and-Filter Architecture
Filters

Source

Pipe

Filter

Pipe

Filter

Pipe

Filter

Pipe

Sink

25/08/2011

Client Server Programming for Applications

27

Pipe-and-Filter Architecture
Example: Unix shell The pipe symbol is | cat takes input data without displaying them grep finds text within a file sort sorts the input data > cat in.txt | grep something | sort > out.txt

in.txt

Pipe

grep

Pipe

sort

Pipe

out.txt

25/08/2011

Client Server Programming for Applications

28

14

25/08/2011

Pipe-and-Filter Architecture
Advantages Useful if many transformation needed Flexible and robust Splitting tasks in smaller sequences which can be performed independently Easy to use filters in different order or extend them Disadvantages Buffer overflow if a filter needs all data to proceed (sorting) Possible deadlocks Needs of specific data types (e.g. characters) complicates the process and slows it down
25/08/2011 Client Server Programming for Applications 29

Event Driven Programming


It is an application architecture technique Sometimes also called event-based programming The program flow is handled by events An event is a signal which can be a sensors input an user action (a mouse click or button press) timers a reaction to another signal Useful for GUI programming For implementation you can use any programming language
25/08/2011 Client Server Programming for Applications 30

15

25/08/2011

Event Driven Programming


To develop an event driven application you have to implement event-handler routines which deal with the events The main program will responds to these events For example: A user clicks a button The corresponding routine opens a new file An event handler is bind to an event The application has a main loop with two sections Event detection Event handling This main loop checks for events and calls the right event handler
25/08/2011 Client Server Programming for Applications 31

Event Driven Programming


Event Source the source of the event to happen provides a way for the event consumer to register and deregister their interest (event handler) Event Consumer the object which is interested in listening to a particular event contains a method for handling events Event Object passed a parameters to the event handler method

25/08/2011

Client Server Programming for Applications

32

16

25/08/2011

Event Driven Programming


Event consumer registers interest Event handler executes List of registered event

Event Consumer
Invokes event handler of registered event consumer

Event Source

Event Object

Event occurs

25/08/2011

Client Server Programming for Applications

33

Event Driven Programming


Limitation The most existing implementation (graphical user interfaces) are not thread-safe The program code can be convoluted or hard to understand Examples Microsoft Visual Basic Java Abstract Window Toolkit (AWT) XwindowProtocol

25/08/2011

Client Server Programming for Applications

34

17

25/08/2011

Application Layers
In the most application architectures the functions are split into modules Each module/layer
has a distinct functionality provides high level services to other modules deploys low level services provides by other modules hides the details of the low level service implementation

Advantages
Reducing the complexity in large programs Reusability of modules Portability across multi-platforms Abstraction
25/08/2011 Client Server Programming for Applications 35

Application Layers
Examples Open Systems Interconnection (OSI) for computer network protocols Computer Architecture Open GL graphics drawing library Stream of bytes models (file I/O, sockets)

25/08/2011

Client Server Programming for Applications

36

18

25/08/2011

Application Layers
Computer Architecture
Operating System Kernel Assembler Firmware Hardware

25/08/2011

Client Server Programming for Applications

37

Application Layers
Example: Bank Money transfer
Sender Fills in the payment form Higher Layer Receiver The receiver can withdraw the money from his account The money is transferred to the receiver account The money is received by the bank computer system

The payment form is insert Middle Layer into the computer system The money is transferred from Lower Layer the bank computer system to the receiver bank system The money is transferred from the source to the destination bank

25/08/2011

Client Server Programming for Applications

38

19

25/08/2011

Application Layers
The functionalities of a network operation system are organized by using different layers called Protocol Stack This stack describes how information is transferred from on software application in one computer through a network to another software application in another computer There are two common connection protocol models: Open Systems Interconnection (OSI) Model TCP/IP Internet Model

25/08/2011

Client Server Programming for Applications

39

Open Systems Interconnection (OSI) Model


Standardized by ISO (International Standards Organization) in 1984 Dominated the networking and data communication literature until 1990s OSI is a set of protocols allowing two different systems to communicate with each other without depending on their underlying architecture 7 layers They can be implemented in software, hardware or both

25/08/2011

Client Server Programming for Applications

40

20

25/08/2011

Open Systems Interconnection (OSI) Model


3 categories for the layers upper layers: dealing with application issues; implemented only in software middle layers: interface between upper and lower layer; implemented on both (software/hardware) lower layers: handling data transport issues; implemented mostly in hardware

25/08/2011

Client Server Programming for Applications

41

Open Systems Interconnection (OSI) Model


Application Presentation Session Upper Layers

Transport Middle Layers Network

Data Link Lower Layers Physical


25/08/2011 Client Server Programming for Applications 42

21

25/08/2011

Open Systems Interconnection (OSI) Model


Lower Layers Physical Layer Lowest layer Transmission and representation of bits Physical characteristics of the interfaces and media Synchronization between the systems Examples: antenna, amplifier, network cables, repeater, hub Data Link Layer Guarantees a reliable and accurate transmission of frames (bit blocks) Flow Control (transfer rate) Error Control Protocols: Ethernet
25/08/2011 Client Server Programming for Applications 43

Open Systems Interconnection (OSI) Model


Middle Layers Network Layer
Transmission of packets Supply of logical addressing Routing between network node/hub Use of Internet Protocols (IP/IPsec)and NSAP addresses

Transport Layer
Transmission of messages Offers a unit access to the upper layers Guarantees a Quality of Services Error Control for end-to-end Flow Control for end-to-end Protocols: TCP, UDP, SCTP
25/08/2011 Client Server Programming for Applications 44

22

25/08/2011

Open Systems Interconnection (OSI) Model


Upper Layers Session Layer
Establishes and manages communication sessions between two systems Persistent logical link between one system to another Offers organized and synchronic data transfer (check points for re-entry) Protocols: Connection-Oriented Session/Connectionless Session

Presentation Layer
Translation of message format between different operating systems (ASCII, EBCDIC, Unicode) Offers a syntactical correct data transfer Additional task like Compression and Encryption

Application Layer
Highest layer Access to the network Obtains services like mail service, file transfer, www, remote login, chatting, etc. Protocols: SMTP, HTTP, NFS, FTP, Telnet
25/08/2011 Client Server Programming for Applications 45

TCP/IP Internet Model


Dominant architecture because it was free provided within the UNIX operating system Sometimes called Internet reference model Consists of 5 layers There is no presentation and session layer Their functions are shared between application and transport layers

25/08/2011

Client Server Programming for Applications

46

23

25/08/2011

TCP/IP Internet Model


Two types of communications take place: Peer-to-Peer communication: same layers on different computers communicating using layer protocol Interface communication: neighbouring (adjacent) layers on the same computer communicating through interfaces Each layer adds control information (meta data) to facilitate communication between layers like source address, destination address, error control information, etc.

25/08/2011

Client Server Programming for Applications

47

TCP/IP Internet Model


Application FTP, SMTP, POP, NNTP, HTTP, TELNET Transport TCP, UDP Middle Layers Network IP Data Link ETHERNET, SATNET, SLIP Lower Layers Physical TDM, FDM, WDM UTP, DSL, ADSL Upper Layers

25/08/2011

Client Server Programming for Applications

48

24

25/08/2011

TCP/IP Internet Model


Client 1
Intermediate nodes

Client 2

Application Peer-to-peer protocol Transport Network Data Link Physical


25/08/2011

Application Transport Network Data Link Physical Network Data Link Physical Network Data Link Physical
49

Client Server Programming for Applications

Resources
Computer Science Program, The University of Texas, Dallas Wikipedia; www.wikipedia.com http://eaipatterns.com/PipesAndFilters.html www.webdevelopersnotes.com http://c2.com/cgi/wiki?EventDrivenProgramming http://www.exforsys.com/tutorials/client-server/peer-to-peer-andclient-queue-client-architecture.html

25/08/2011

Client Server Programming for Applications

50

25

25/08/2011

Any questions?

25/08/2011

Client Server Programming for Applications

51

26

You might also like