The Client-Server Paradigm

Slides:



Advertisements
Similar presentations
Multiplexing/Demux. CPSC Transport Layer 3-2 Multiplexing/demultiplexing application transport network link physical P1 application transport network.
Advertisements

Using TCP sockets in Java Created by M Bateman, A Ruddle & C Allison As part of the TCP View project.
Socket Programming By Ratnakar Kamath. What Is a Socket? Server has a socket bound to a specific port number. Client makes a connection request. Server.
Jan Java Networking UDP Yangjun Chen Dept. Business Computing University of Winnipeg.
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.
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.
1 Java Networking – Part I CS , Spring 2008/9.
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
1 Overview r Socket programming with TCP r Socket programming with UDP r Building a Web server.
System Programming Practical session 10 Java sockets.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
Client Server Paradigm
An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.
Distributed Computing, Liu1 The Client-Server Model – part 1 M. L. Liu.
Server Design Discuss Design issues for Servers Review Server Creation in Linux.
Building an ftp client and server using sockets we now know enough to build a sophisticated client/server application!  ftp  telnet  smtp  http.
Babak Esfandiari (based on slides by Qusay Mahmoud)
CS 352-Socket Programming & Threads Dept. of Computer Science Rutgers University (Thanks,this slides taken from er06/
CS4273: Distributed System Technologies and Programming I Lecture 5: Java Socket Programming.
The Client-Server Model – part II
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
UDP vs TCP UDP Low-level, connectionless No reliability guarantee TCP Connection-oriented Not as efficient as UDP.
Practicum: - Client-Server Computing in Java Fundamental Data Structures and Algorithms Margaret Reid-Miller 13 April 2004.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
Object Oriented Programming in Java Lecture 16. Networking in Java Concepts Technicalities in java.
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.
Networks Sockets and Streams. TCP/IP in action server ports …65535 lower port numbers ( ) are reserved port echo7 time13 ftp20 telnet23.
 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(1/11) Java Sockets and Simple Networking Joel Adams and Jeremy Frens.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Networking and Concurrency COMP.
1 cs205: engineering software university of virginia fall 2006 Network Programming* * Just enough to make you dangerous Bill Cheswick’s map of the Internet.
CS390- Unix Programming Environment CS 390 Unix Programming Environment Java Socket Programming.
Position of application layer. Application layer duties.
Networking Java (2/3)
1 Client-Server Interaction. 2 Functionality Transport layer and layers below –Basic communication –Reliability Application layer –Abstractions Files.
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.
By Vivek Dimri. Basic Concepts on Networking IP Address – Protocol – Ports – The Client/Server Paradigm – Sockets The Java Networking Package – The InetAddress.
TCP/IP Protocol Stack IP Device Drivers TCPUDP Application Sockets (Gate to network) TCP: –Establish connection –Maintain connection during the communication.
Java Programming II Java Network (I) Java Programming II.
1 CSCD 330 Network Programming Fall 2013 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 8a Application.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Netprog: Client/Server Issues1 Issues in Client/Server Programming Refs: Chapter 27.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Java API for distributed computing.
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
Java Networking I IS Outline  Quiz #3  Network architecture  Protocols  Sockets  Server Sockets  Multi-threaded Servers.
1 K. Salah Application Layer Module K. Salah Network layer duties.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 33 Networking.
Object-Orientated Analysis, Design and Programming
Echo Networking COMP
Threads in Java Two ways to start a thread
Client-Server and Multicast Communication
MCA – 405 Elective –I (A) Java Programming & Technology
Client-server Programming
Networking with Java 2.
Client/Server Example
Client-Server Interaction
Issues in Client/Server Programming
Socket Programming.
Internet Applications & Programming
An Introduction to Internetworking
Multiplexing/Demux.
CS18000: Problem Solving and Object-Oriented Programming
Based on Java Network Programming and Distributed Computing
Review Communication via paired sockets, one local and one remote
Presentation transcript:

The Client-Server Paradigm 11/25/2018

Introduction The Client-Server paradigm is the most prevalent model for distributed computing protocols. It is the basis of all distributed computing paradigms at a higher level of abstraction. It is service-oriented, and employs a request-response protocol. 11/25/2018

The Client-Server Paradigm A server process, running on a server host, provides access to a service. A client process, running on a client host, accesses the service via the server process. The interaction of the process proceeds according to a protocol. 11/25/2018

Client-server applications and services An application based on the client-server paradigm is a client-server application. On the Internet, many services are Client-server applications. These services are often known by the protocol that the application implements. Well known Internet services include HTTP, FTP, DNS, finger, gopher, etc. User applications may also be built using the client-server paradigm. 11/25/2018

11/25/2018

Connectionless Server A connectionless server accepts one request at a time from any client, processes the request, and sends the response to the requestor. 11/25/2018

Connection-Oriented Client-Server applications A client-server application can be either connection-oriented or connectionless. In a connection-oriented client-server application: The server is passive: it listens and waits for connection requests from clients, and accepts one connection at a time. A client issues a connection request, and waits for its connection to be accepted. Once a server accepts a connection, it waits for a request from the client. When a client is connected to the server, it issues a request and waits for the response. When a server receives a request, it processes the request and sends a response, then wait for the next request, if any. The client receives the request and processes it. If there are further requests, the process repeats itself until the protocol is consumated. 11/25/2018

Connectionless Echo Server DatagramSocket ds = new DatagramSocket(port); while (true) { try { // create a new datagram packet byte[] buffer = new byte[MAXLEN]; DatagramPacket dp = new DatagramPacket(buffer, MAXLEN); ds.receive(dp); len = dp.getLength(); cAddr = dp.getAddress(); cPort = dp.getPort(); String s = new String(dp.getData(), 0, len); System.out.println(dp.getAddress() + " at port " + dp.getPort() + " says " + s); // create a datagram packet to send to client DatagramPacket theEcho = new DatagramPacket(buffer,len, cAddr, cPort); ds.send(theEcho); } // end try … } // end while 11/25/2018

The Basic Connection-Oriented Client-Server Model 11/25/2018

Concurrent, Connection-Oriented Server A connection-oriented server services one client at a time. If the duration of each client session is significant, then the latency or turnaround time of a client request becomes unacceptable if the number of concurrent client processes is large. To improve the latency, a server process spawns a child process or child thread to process the protocol for each client. Such a server is termed a concurrent server, compared to an iterative server. 11/25/2018

Concurrent, connection-oriented server - 2 A concurrent server uses its main thread to accept connections, and spawns a child thread to process the protocol for each client. Clients queue for connection, then are served concurrently. The concurrency reduces latency significantly. 11/25/2018

Connection-oriented server: latency analysis For a given server S, let Tc be the expected time that S takes to accept a connection, and Tp be the expected time S takes to process the protocol for a client. Further assume that the expected number of concurrent clients requiring the service of S is N. 11/25/2018

Connection-oriented Daytime Server … theServer = new ServerSocket(thePort); p = new PrintWriter(System.out); try { p.println("Echo Server now in business on port " + thePort ); p.flush(); theConnection = theServer.accept(); // read a line from the client theInputStream = new BufferedReader (new InputStreamReader (theConnection.getInputStream())); p = new PrintWriter(theConnection.getOutputStream()); while (!done){ theLine = theInputStream.readLine(); if (theLine == null) done = true; else{ p.println(theLine); } theConnection.close(); Connection acceptance Protocol processing 11/25/2018

Connection-oriented Concurrent DayTime Server ConcurrentDaytimeServer Connection-oriented Concurrent DayTime Server ConcurrentDaytimeServer.java DaytimeServerThread.java theServer = new ServerSocket(thePort); p = new PrintWriter(System.out); try { p.println("dayTime Server now in business on port " + thePort ); p.flush(); while (true) { theConnection = theServer.accept(); daytimeServerThread theThread = new daytimeServerThread(theConnection); theThread.start(); } public class daytimeServerThread extends Thread { Socket theConnection; public daytimeServerThread(Socket s) { theConnection = s; } public void run() { try { PrintWriter p; p = new PrintWriter(theConnection.getOutputStream()); p.println(new Date()); p.flush(); theConnection.close(); catch (IOException e) { System.err.println(e); } // end try } // end thread class 11/25/2018

Connection-oriented Echo Server public class echoServer { public static void main(String[] args) { ServerSocket theServer; int thePort; Socket theConnection; PrintWriter p; BufferedReader theInputStream; String theLine; boolean done = false; … theServer = new ServerSocket(thePort); p = new PrintWriter(System.out); try { theConnection = theServer.accept(); // read a line from the client theInputStream = new BufferedReader (new InputStreamReader (theConnection.getInputStream())); p = new PrintWriter(theConnection.getOutputStream()); while (!done){ theLine = theInputStream.readLine(); if (theLine == null) done = true; else { p.println(theLine); p.flush(); } // end if } //end while theConnection.close(); } // end try … 11/25/2018

Concurrent Echo Server See ConcurrentEchoServer.java See EchoServerThread.java 11/25/2018

Stateful server A stateful server maintain stateful information on each active client. Stateful information can reduce the data exchanged, and thereby the response time. 11/25/2018

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. 11/25/2018

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. 11/25/2018

A client can contact multiple servers A process may require the service of 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. 11/25/2018

Middleware A process can serve as a intermediary, or middleware, between a client and a server. 11/25/2018