1 / 16

Introduction

Introduction. Chapter 1. Part III Client/Server Organization. Process Organization. How are processes organized in a DS? Client/Server: very famous model Server : A process implementing a specific service (Web site, file system) Client : a process that requests a service from the server.

lila-ford
Download Presentation

Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction Chapter 1 Part III Client/Server Organization

  2. Process Organization • How are processes organized in a DS? • Client/Server: very famous model • Server: A process implementing a specific service (Web site, file system) • Client: a process that requests a service from the server

  3. Clients and Servers 1.25 • General interaction between a client and a server.

  4. An Example Client/Server (1) • import java.io.*; • import java.net.*; • class Server { • public static void main(String a[]) throws IOException { • int port = 1969; //some port! • Socket s; • // Create a server socket • ServerSocket ss = new ServerSocket(port); • // daemon like thing • while (true) { • s = ss.accept(); // accept a new client connection • /* CODE TO PROCESS REQUEST HERE */}}} Simple Server

  5. An Example Client/Server (2) • // I/O streams for the socket • BufferedReader is = null; • PrintStream os = null; • // Get these I/O streams • try { • is = new BufferedReader(new • InputStreamReader(s.getInputStream())); • os = new PrintStream(s.getOutputStream()); • // send your greating to the client • os.println("Waiting for your request."); • os.flush(); Simple Server

  6. An Example Client and Server (3) • /* receive the client's request. Example request: 1:source.txt */ • String request = is.readLine(); • /* PROCESS COMMAND */ • // close "this" connection with the client • s.close(); • } • catch (IOException e) { • System.out.println("IO Exception: " + e); • } • } Simple Server

  7. An Example Client and Server (4) • import java.io.*; • import java.net.*; • class Client { • public static void main(String a[]) throws IOException { • int port = 1969; //some port! • // open the connection to the server • Socket s = new Socket("jalal", port); //my machine • // get I/O streams • PrintStream os = new PrintStream(s.getOutputStream()); • BufferedReader is = new BufferedReader(new • InputStreamReader(s.getInputStream())); Simple Client

  8. An Example Client and Server (5) • // get the server welcome message • System.out.println("Server says: " + is.readLine()); • // send a request to the server • os.println(<some request>); • os.flush(); • // receive the servers response • System.out.println("Server Says: " + is.readLine()); • s.close(); • } • } Simple Client

  9. An Example Client and Server (6) • DataInputStream is = new DataInputStream(s.getInputStream()); • readLine is depricated in DataInputStream • System.out.println("Server says: " + is.readLine()); • BufferedReader is = new BufferedReader(new InputStreamReader(s.getInputStream())); Simple Client

  10. 3-Level Processing Vertical Distribution User Interface Application Server Data Server

  11. 3-Level Processing 1-28 • The general organization of an Internet search engine into three different layers

  12. Multitiered Architectures (1) 1-29 • Alternative client-server organizations (a) – (e).

  13. Multitiered Architectures (2) 1-30 • An example of a server acting as a client.

  14. Modern Architectures Horizontal Distribution 1-31 • An example of horizontal distribution of a Web service.

  15. Modern Architectures Web Server Presentation Server Application Server Data Server

  16. Modern Architectures XML Output Queries/ Responses Client Server Client Request Client Request App Server Web Server HTML WML Data Server Presentation Server Server Response

More Related