Concurrent vs. iterative servers

Slides:



Advertisements
Similar presentations
Elementary TCP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
Advertisements

1 Elementary TCP Sockets socket function connect function bind function listen function accept function fork and exec functions Concurrent servers close.
1 Chapter 6 Datagram Delivery by UDP Just as the Internet Protocol uses the services of subnetworks, transport protocols build upon the services of IP.
28.2 Functionality Application Software Provides Applications supply the high-level services that user access, and determine how users perceive the capabilities.
Data Communications and Networking (Third Edition)
Slide 1 Client / Server Paradigm. Slide 2 Outline: Client / Server Paradigm Client / Server Model of Interaction Server Design Issues C/ S Points of Interaction.
Process Control Hua LiSystems ProgrammingCS2690Process Control Page 1 of 41.
1 Processes and Pipes COS 217 Professor Jennifer Rexford.
1 Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write)
Fork Fork is used to create a child process. Most network servers under Unix are written this way Concurrent server: parent accepts the connection, forks.
1 Data Communications and Networking Socket Programming Part II: Design of Server Software Reference: Internetworking with TCP/IP, Volume III Client-Server.
CS 311 – Lecture 18 Outline IPC via Sockets – Server side socket() bind() accept() listen() – Client side connect() Lecture 181CS Operating Systems.
Process Control in Unix Operating Systems Hebrew University Spring 2004.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
© Lethbridge/Laganière 2001 Chap. 3: Basing Development on Reusable Technology 1 Let’s get started. Let’s start by selecting an architecture from among.
CSE 451 Section 4 Project 2 Design Considerations.
Advanced UDP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.
Fork and Exec Unix Model Tutorial 3. Process Management Model The Unix process management model is split into two distinct operations : 1. The creation.
Client Server Model and Software Design TCP/IP allows a programmer to establish communication between two application and to pass data back and forth.
Chapter 26 Client Server Interaction Communication across a computer network requires a pair of application programs to cooperate. One application on one.
Server Design Discuss Design issues for Servers Review Server Creation in Linux.
Hands On Networking Socket Programming Ram P Rustagi, ISE Dept Abhishek Gupta, ISE Dept Laxmi Kuber, MCA Dept June 28-30, 2012.
Elementary TCP Sockets
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Today’s topic Other server design alternatives –Preforked servers –Threaded servers –Prethreaded servers.
Lecture 5 Process, Thread and Task September 22, 2015 Kyu Ho Park.
Operating Systems Recitation 9, May 19-20, Iterative server Handle one connection request at a time. Connection requests stored in queue associated.
Elementary TCP Sockets
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
Chapter 2 Applications and Layered Architectures Sockets.
The Socket Interface Chapter 21. Application Program Interface (API) Interface used between application programs and TCP/IP protocols Interface used between.
The Socket Interface Chapter 22. Introduction This chapter reviews one example of an Application Program Interface (API) which is the interface between.
1 Server Design Discuss Design issues for Servers Review Server Creation in Windows.
Position of application layer. Application layer duties.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 3.1 Internet Applications Ch. 28,… (Client-Server Concept, Use of Protocol Ports, Socket API)
1 Daemons & inetd Refs: Chapter Daemons A daemon is a process that: –runs in the background –not associated with any terminal Unix systems typically.
Processes CSCI 4534 Chapter 4. Introduction Early computer systems allowed one program to be executed at a time –The program had complete control of the.
Process to process communication over network connections Includes references to Comer and Stevens Internetworking with TCP/IP vol 3 Client-server programming.
Cs423-cotter1 Concurrency Issues in Client/Server Applications Chapters 15,16, 28.
1 Client-Server Interaction. 2 Functionality Transport layer and layers below –Basic communication –Reliability Application layer –Abstractions Files.
What is a Process? u A process is an executable “cradle” in which a program may run u This “cradle” provides an environment in which the program can run,
Client/Server Socket Programming Project
Part 4: Network Applications Client-server interaction, example applications.
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl1 1 Chapter 15 Application Layer and Client-Server.
Single Process, Concurrent, Connection-Oriented Servers (TCP) (Chapter 12)
Process Management Azzam Mourad COEN 346.
Berkeley Socket Abstraction
Concurrent Servers. Idea Behind Concurrent Servers Server Client 1 Server 1 X.
Simple Socket Server m Yumiko Kimezawa September 19, 20121RPS.
UNIX Sockets Outline UNIX sockets CS 640.
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl1 1 Chapter 16 Socket Interface.
Tutorial 3. In this tutorial we’ll see Fork() and Exec() system calls.
1 Dimension of Server Designs r Iterative vs Concurrent r Connection-oriented vs. connectionless r Stateful and stateless m Constrained by application.
Netprog: Client/Server Issues1 Issues in Client/Server Programming Refs: Chapter 27.
Client-Server Programming and Applications. References Douglas Comer, David Stevens, “Internetworking with TCP/IP: Client-Server Programming and Applications”,
1 K. Salah Application Layer Module K. Salah Network layer duties.
Linux/UNIX Programming APUE (Process Control) 문양세 강원대학교 IT 대학 컴퓨터과학전공.
1 Issues in Client/Server Refs: Chapter 27 Case Studies RFCs.
Concurrent vs. iterative servers
CH5 TCP Client - Server Example:
Chapter4 Elementary TCP Socket
CHAPTER 8 ELEMENTARY UDP SOCKETS
Fork and Exec Unix Model
Advanced Network Programming spring 2007
Process Creation Process Termination
Tutorial 3 Tutorial 3.
Chien-Chung Shen CIS/UD
Network Programming CSC- 341
Issues in Client/Server Programming
Presentation transcript:

Concurrent vs. iterative servers process one request at a time Easy to build Unnecessary delay Concurrent server handles multiple requests at one time. More difficult to design and build Better performance

Fork and exec functions #incllude<unistd.h> int fork(); Return 0 in child, process ID of child in parent –1 on error There are two typical uses of fork A process makes a copy of itself so that one copy handle one operation while the other copy does another task. A process wants to execute another program. Since the only way to create a new process is by calling fork, the process first calls fork to make a copy of itself, and then one of the copies(child) calls exec to replace itself with the new program

exec #include<unistd.h> int execl(const char *pathname, const char *arg0,…); int execv(const char *pathname, char *const argv[]); int execle(const char *pathname, const char *arg0,…, ); int execve(const char *pathname, char *constargv[], char *constenvp[]); int execlp(const char *filename, const char *arg0,…); int execvp(const char *filename, char *const argv[]); All sizr return –1 on error, no return on sucess

Outline for typical concurrent server int pid,s, conn; S = Socket( .. ); // fill in server address Bind(s, ..); Listen(s, LISTNQ); while(1){ conn = Accept(s, ..); if( (pid = fork()) ==0) { close (s); doit( conn); close(conn); exit(0); } // end of if }// end of while loop

Concurrent, connection-oriented Connection-oriented servers implement concurrency among connections rather than among individual requests. Connection between client-server handle more than a single request: The protocol allow a client to repeatedly send requests and receive responses without terminating the connection or creating a new one.

Algorithm-parent,madter Create a socket and bind to the well-known address for the service being offered. Leave the socket unconnected Place the socket in passive mode, making it ready for use by a server. Repeatedly call accept to receive the next request from a client, and create a new process to handle the response

Algorithm-child,slave Begin with a connection passed from the master(I.e. a socket for the connection) Interact with the client using the connection: read request(s) and send back response(s) Close the connection and exit. The slave exits after handling all requests from one client

Apparent concurrency using a single thread Create a socket and bind to the well-known port for the service.add socket to the list of those on which I/O is possible. Use select to wait for I/O on existing sockets If original socket is ready, use accept to obtain the next connection, and add the new socket to the list of those on which I/O is possible. If some socket other than the original is ready, use recv and read to obtain the next request, forma response, and use send or write to send the response back to the client Continue processing with step 2.