The Client-Server Model – part II

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

Socket Programming ENTERPRISE JAVA. 2 Content  Sockets  Streams  Threads  Readings.
Multiplexing/Demux. CPSC Transport Layer 3-2 Multiplexing/demultiplexing application transport network link physical P1 application transport network.
28.2 Functionality Application Software Provides Applications supply the high-level services that user access, and determine how users perceive the capabilities.
20 februari 2006 Client-Server and Multicast Communication 1 René de Vries Based on slides by M.L. Liu and M. van Eekelen.
Network Programming Chapter 11 Lecture 6. Networks.
Interprocess Communications
2: Application Layer 1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 17 Introduction to the Application.
1 Overview r Socket programming with TCP r Socket programming with UDP r Building a Web server.
Computer Science Lecture 2, page 1 CS677: Distributed OS Last Class: Introduction Distributed Systems – A collection of independent computers that appears.
Client Server Paradigm
TCP Socket Programming CPSC 441 Department of Computer Science University of Calgary.
Multithreading in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.
Server issues How to approach the design of servers.
1 The Client-Server Model – part 1. 2 Introduction The Client-Server paradigm is the most prevalent model for distributed computing protocols. It is the.
Distributed Computing, Liu1 The Client-Server Model – part 1 M. L. Liu.
Fundamentals of Python: From First Programs Through Data Structures
Chapter 26 Client Server Interaction Communication across a computer network requires a pair of application programs to cooperate. One application on one.
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
TCP/IP protocols Communication over Internet is mostly TCP/IP (Transmission Control Protocol over Internet Protocol) TCP/IP "stack" is software which allows.
Chapter – Background 5.2 Client Server Paradigm Issues 5.3 Software Engineering for a Network Service 5.4 Connection-Oriented and Connectionless.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Servlets Pranav Maydeo. What is a Servlet ? Servlets are modules of Java code that run in a server application to answer client requests. Servlets are.
Li Tak Sing COMPS311F. Static attributes in Servlets Since Servlets are also Java classes, you can also use static attributes to store values that can.
Cli/Serv.: Chat/121 Client/Server Distributed Systems v Objectives –discuss a client/server based chat system –mention two other ways of chatting.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
Java Servlets & Java Server Pages Lecture July 2013.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
IBM TSpaces Lab 1 Introduction. Summary TSpaces Overview Basic Definitions Basic primitive operations Reading/writing tuples in tuplespace HelloWorld.
Advanced Computer Networks Topic 2: Characterization of Distributed Systems.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Li Tak Sing COMPS311F. Case study: consumers and producers A fixed size buffer which can hold at most certain integers. A number of producers which generate.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Networking and Concurrency COMP.
CS390- Unix Programming Environment CS 390 Unix Programming Environment Java Socket Programming.
Dynamic Architectures (Component Reconfiguration) with Fractal.
Threaded Programming in Python Adapted from Fundamentals of Python: From First Programs Through Data Structures CPE 401 / 601 Computer Network Systems.
Maintaining Application State MIS3502: Application Integration and Evaluation Paul Weinberg Presentation by David Schuff.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
Interprocess Communications
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session II: Introduction to Server-Side Web Development with Servlets.
1 Client-Server Interaction. 2 Functionality Transport layer and layers below –Basic communication –Reliability Application layer –Abstractions Files.
Copyright © 2002 ProsoftTraining. All rights reserved. Java Servlets.
The Client-Server Model And the Socket API. Client-Server (1) The datagram service does not require cooperation between the peer applications but such.
Part 4: Network Applications Client-server interaction, example applications.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Session Beans Based on: Patel, Brose, Silverman, Mastering Enterprise JavaBeans 3.0.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Venkita Subramonian, Christopher Gill, Ying Huang, Marc Sentany Department of Computer Science.
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
1 COMP 431 Internet Services & Protocols Client/Server Computing & Socket Programming Jasleen Kaur February 2, 2016.
Distributed Systems CS Project 1: File Storage and Access Kit (FileStack) Recitation 1, Aug 29, 2013 Dania Abed Rabbou and Mohammad Hammoud.
CSC 480 Software Engineering Lab 2 – Multi-Threading Oct 18, 2002.
Java Networking I IS Outline  Quiz #3  Network architecture  Protocols  Sockets  Server Sockets  Multi-threaded Servers.
OOSD Using Java CBTS Framework. 11/2/04CBTS2 Servlet  A servlet is a Java program that can extends Web server’s functionality.  Servlets interact with.
Concurrency in Java MD. ANISUR RAHMAN. slide 2 Concurrency  Multiprogramming  Single processor runs several programs at the same time  Each program.
R Some of these slides are from Prof Frank Lin SJSU. r Minor modifications are made. 1.
Distributed Computing, M. L. Liu 1 Interprocess Communications Mei-Ling L. Liu.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
Servlet Fudamentals.
Java Servlets By: Tejashri Udavant..
Client-server Programming
Client-Server Interaction
The Client-Server Paradigm
Threaded Programming in Python
CS122B: Projects in Databases and Web Applications Winter 2019
Multiplexing/Demux.
Presentation transcript:

The Client-Server Model – part II

Connectionless server vs. connection-oriented server

Connectionless vs. Connection-Oriented Server A connectionless server Uses a connectionless IPC API (e.g., connectionless datagram socket) Sessions with concurrent clients can be interleaved. A connection-oriented server Uses a connection-oriented IPC API (e.g. stream-mode socket ) Sessions with concurrent clients can only be sequential unless the server is threaded.

EchoServer1 (Connectionless--UDP) public class EchoServer1 { public static void main(String[] args) { … // instantiates a datagram socket for both sending // and receiving data MyServerDatagramSocket mySocket = new MyServerDatagramSocket(serverPort); while (true) { // forever loop DatagramMessage request = mySocket.receiveMessageAndSender(); String message = request.getMessage( ); mySocket.sendMessage(request.getAddress( ), request.getPort( ), message); } //end while http://ise.gmu.edu/~yhwang1/SWE622/Sample_Codes/chapter5

Concurrent client sessions with EchoServer1 Messages from clients will be lost if the server is not ready yet.

EchoServer2 (Connection-oriented--TCP) ServerSocket myConnectionSocket = new ServerSocket(serverPort); while (true) { // forever loop MyStreamSocket myDataSocket = new MyStreamSocket ( myConnectionSocket.accept( ) ); boolean done = false; while (!done) { message = myDataSocket.receiveMessage( ); if ((message.trim()).equals (endMessage)){ myDataSocket.close( ); done = true; } //end if else { myDataSocket.sendMessage(message); } //end else } //end while !done } //end while forever http://ise.gmu.edu/~yhwang1/SWE622/Sample_Codes/chapter5

Two Consecutive client sessions-- EchoServer2

Iterative servers Vs. Concurrent servers

Concurrent Server A connection-oriented server can be threaded so that it can serve multiple clients concurrently/simultaneously. Such a server is said to be a concurrent server. An unthreaded connection-oriented server is said to be an iterative server (e.g., EchoServer2).

A Concurrent, Connection-oriented Server

Sequence diagram – EchoServer3

EchoServer3 (concurrent server) ServerSocket myConnectionSocket = new ServerSocket(serverPort); while (true) { // forever loop MyStreamSocket myDataSocket = new MyStreamSocket myConnectionSocket.accept( )); Thread aThread = new Thread(new ServerThread(myDataSocket)); aThread.start(); } //end while forever http://ise.gmu.edu/~yhwang1/SWE622/Sample_Codes/chapter5

ServerThread Class class ServerThread implements Runnable { static final String endMessage = "."; MyStreamSocket myDataSocket; EchoServerThread(MyStreamSocket myDataSocket) { this.myDataSocket = myDataSocket; } public void run( ) { boolean done = false; String message; try { // put in here the logic for each client session while (!done) { message = myDataSocket.receiveMessage( ); if ((message.trim()).equals (endMessage)){ myDataSocket.close( ); done = true; } //end if else { myDataSocket.sendMessage(message); } //end else } //end while !done }// end try catch (Exception ex) { ….. } } //end run } //end class

Echo3Server Concurrent Sessions

Server Thread class Template class ServerThread implements Runnable { static final String endMessage = "."; MyStreamSocket myDataSocket; ServerThread(MyStreamSocket myDataSocket) { this.myDataSocket = myDataSocket; } public void run( ) { boolean done = false; String message; try { //add code here }// end try catch (Exception ex) { System.out.println("Exception caught in thread: " + ex); } } //end run } //end class

Stateful Servers vs. Stateless Servers

Session State Information For some protocols or applications, a server must maintain information specific to a client during its service session. Consider a network service such as file transfer. A file is typically transferred in blocks, requiring several rounds of data exchanges to complete the file transfer. The dialog during a session proceeds roughly as follows: Client: Please send me the file foo in directory someDir. Server: Okay. Here is block1 of the file Client: Got it. Server. Okay. Here is block2 of the file … Server. Okay. Here is block3 of the file

Stateful Server A stateful server maintains stateful information on each active client. Stateful information can reduce the data exchanged, and thereby the response time.

Stateful vs. Stateless Server Stateless server is straightforward to code. Stateful server is harder to code, but the state information maintained by the server can reduce the data exchanged, and allows enhancements to a basic service. Maintaining stateful information is difficult in the presence of failures.

Session State Information - 2 With a protocol such as ftp, there is a need for the server to keep track of the progress of the session, such as which block of the file needs to be fetched next. A server does so by maintaining a set of state for each session, known as the session state data. For the file transfer protocol, the session state data may include the name of the file being transferred, and the current block count. Another example of a stateful protocol is one for a shopping cart application. Each session must maintain state data that keeps track of the identifier of the shopper and the cumulative contents of the shopping cart.

State Data Storage In our example, the state data – the sleep time interval - is stored in a local variable in the run method of each thread. Since each client is serviced by a separate thread, the local variable suffices as a storage for the state data.   Using local variables in a thread to store session state data is adequate for a network service server. In complex network applications such as shopping carts, more complex mechanisms are needed for state data storage.

HTTP Session session.putValue (“Department", “ISE”); public class SWE622 extends HttpServlet { public void init(ServletConfig config) throws ServletException { super.init(config); } public void service ( HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { … HttpSession session = req.getSession(true); session.putValue (“Department", “ISE”); session.putValue (“University", “GMU”); … }

Stateful vs. Stateless Server In actual implementation, a server may be Stateless Stateful A hybrid, wherein the state data is distributed on both the server-side and the client-side. Which type of server is chosen is a design issue.

A client can contact multiple servers A client process may require the services from different multiple servers. For example, it may obtain a timestamp from a daytime server, data from a database server, and a file from a file server.

Summary You have been introduced to the client-server paradigm in distributed computing. Topics covered include: The difference between the client-server system architecture and the client-server distributed computing paradigm. Definition of the paradigm and why it is widely adopted in network services and network applications. The issues of service sessions, protocols, service location, interprocess communications, data representation, and event synchronization in the context of the client-server paradigm. The three-tier software architecture of network applications: Presentation logic, application logic, and service logic. Connectionless server versus connection-oriented server. Iterative server versus concurrent server and the effect on a client session. Stateful server versus stateless server. In the case of a stateful server: global state information versus session state information.