The Client-Server Model And the Socket API. Client-Server (1) The datagram service does not require cooperation between the peer applications but such.

Slides:



Advertisements
Similar presentations
Umut Girit  One of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer.
Advertisements

CCNA – Network Fundamentals
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)
CS335 Networking & Network Administration Tuesday, May 25, 2010.
UDP - User Datagram Protocol UDP – User Datagram Protocol Author : Nir Shafrir Reference The TCP/IP Guide - ( Version Version.
Socket Programming.
1 Java Networking – Part I CS , Spring 2008/9.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
CSCI 4550/8556 Computer Networks Comer, Chapter 3: Network Programming and Applications.
1 Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write)
UDP: User Datagram Protocol. UDP: User Datagram Protocol [RFC 768] r “bare bones”, “best effort” transport protocol r connectionless: m no handshaking.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
1 Computer Networks and Internets, 5e By Douglas E. Comer Lecture PowerPoints Adapted from the notes By Lami Kaya, © 2009 Pearson Education.
What Is TCP/IP? The large collection of networking protocols and services called TCP/IP denotes far more than the combination of the two key protocols.
Client Server Model and Software Design TCP/IP allows a programmer to establish communication between two application and to pass data back and forth.
I NTRODUCTION OF S OCKET P ROGRAMMING L.Aseel AlTurki King Saud University.
Chapter 26 Client Server Interaction Communication across a computer network requires a pair of application programs to cooperate. One application on one.
CSIT 320 (Blum)1 Client-Server Interaction Based on Appendix 1 in Computer Networks and Internets, Comer.
Process-to-Process Delivery:
1 Transport Layer Computer Networks. 2 Where are we?
Assignment 3 A Client/Server Application: Chatroom.
TCP/IP protocols Communication over Internet is mostly TCP/IP (Transmission Control Protocol over Internet Protocol) TCP/IP "stack" is software which allows.
Chapter 17 Networking Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Firewall and Internet Access Mechanism that control (1)Internet access, (2)Handle the problem of screening a particular network or an organization from.
IP and Errors IP Best Effort Datagrams can be: –Lost –Delayed –Duplicated –Delivered out of order –Corrupted.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
Server Sockets: A server socket listens on a given port Many different clients may be connecting to that port Ideally, you would like a separate file descriptor.
Internet Applications and Network Programming Dr. Abraham Professor UTPA.
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 26.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 2.5 Internetworking Chapter 25 (Transport Protocols, UDP and TCP, Protocol Port Numbers)
User Datagram Protocol (UDP) Chapter 11. Know TCP/IP transfers datagrams around Forwarded based on destination’s IP address Forwarded based on destination’s.
Copyright © Curt Hill, Client – Server Computing An important paradigm.
Chapter 4: Interprocess Communication‏ Pages
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
1. I NTRODUCTION TO N ETWORKS Network programming is surprisingly easy in Java ◦ Most of the classes relevant to network programming are in the java.net.
Inter-process communication: Socket. socket Internet socket From Wikipedia, the free encyclopedia Jump to: navigation,
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.
CS 158A1 1.4 Implementing Network Software Phenomenal success of the Internet: – Computer # connected doubled every year since 1981, now approaching 200.
Distributed Computing A Programmer’s Perspective.
Client-Server Model of Interaction Chapter 20. We have looked at the details of TCP/IP Protocols Protocols Router architecture Router architecture Now.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 3.1 Internet Applications Ch. 28,… (Client-Server Concept, Use of Protocol Ports, Socket API)
Chapter 27 Socket API Interface The interface between an application program and the communication protocols in an operating system is known as the Application.
1 Client-Server Interaction. 2 Functionality Transport layer and layers below –Basic communication –Reliability Application layer –Abstractions Files.
Part 4: Network Applications Client-server interaction, example applications.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
1 Kyung Hee University Chapter 11 User Datagram Protocol.
UDP: User Datagram Protocol Chapter 12. Introduction Multiple application programs can execute simultaneously on a given computer and can send and receive.
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets, 5e By Douglas E. Comer Lecture PowerPoints.
Ch 2. Application Layer Myungchul Kim
Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan.
Client-server communication Prof. Wenwen Li School of Geographical Sciences and Urban Planning 5644 Coor Hall
1 K. Salah Application Layer Module K. Salah Network layer duties.
Process-to-Process Delivery:
1 Chapter 24 Internetworking Part 4 (Transport Protocols, UDP and TCP, Protocol Port Numbers)
Sockets and Beginning Network Programming
Chapter 3 Internet Applications and Network Programming
Client/Server Example
Client-Server Interaction
Interacting With Protocol Software
TCP/IP Networking An Example
Process-to-Process Delivery:
Internet Applications & Programming
Presentation transcript:

The Client-Server Model And the Socket API

Client-Server (1) The datagram service does not require cooperation between the peer applications but such cooperation is essential for the stream service –The coordination is usually achieved through a client- server model A server starts first and waits to be contacted –It does not know which clients will contact it –It continues to run after servicing one client A client starts second and initiates the connection –It must know what server to contact –It initiates contact only when necessary 2

Client-Server (2) When used with the datagram service the client- server model often has request-reply semantics –For example, make a request to the database server in a short message and expect a short message back as a reply –If no reply is received, just repeat the request When used with the stream service – –Once the bi-directional connection is open data can flow from client to server or from server to client –The client and server terms describe who initiates contact 3

Client-Server (3) An application may have both server and client relationships to other applications –Circular relationships can lead to a deadlock  A client application may contact multiple server applications during a session A server application may support multiple clients The point here is that the client-server relationship is somewhat of an atomic building block. Applications may have many relationships with other applications and functions as clients or servers depending on the communication 4

Client-Server (4) Client and server behaviors are often confused with hardware capability –The terms server or client could therefore mean hardware or software A “server-class” computer may run multiple server applications –The client-server model concentrates traffic at the server Multiple clients may simultaneously contact the same server hardware –This is potentially a network bottleneck 5

Client-Server (5) An alternative is the peer-to-peer model –A computer runs both client and server parts of an application –Data is distributed among all of the members of the peer-to-peer network –When the application is acting as a client it contacts multiple applications which act as servers Only a fraction of the data is obtained from any one server application – thus distributing the load –Peer-to-peer was popularized by networks set up to illegally share multimedia files (e.g., Napster) but it can be used for more legitimate purposes 6

Client-Server (6) How does a client identify a server? In the IP stack an application service is identified in two steps: –Identify the hardware interface where the service can be reached i.e., the computer where the server is running A computer may have more than one interface and the service may only be “listening” on one interface –Identify which service at that interface is of interest Because the computer may be running multiple services 7

Client-Server (7) Identifying the interface? –Each interface is assigned a unique identifier at the Internet layer known as an IP address –The server’s IP address will be the destination address in the IP header –Each computer is also assigned a name The mapping between the names and the IP addresses is maintained in the Domain Name System (DNS) service –Client software accepts the name of the computer where the server is located and silently translates the name to an address using DNS A failure of the DNS service can therefore lead users to believe that the service they are trying to contact has failed 8

Client-Server (8) Identifying a service? –Each service is assigned a unique 16-bit identifier known as a port number at the transport layer e.g.,  port number 25, web  port number 80 –When a server starts it registers with its local OS by specifying its port number –When a client contacts a remote server to request service the request contains a port number in the transport-layer protocol header –When a request arrives at a server the transport layer protocol uses the port number in the request to determine which application should handle the request 9

Sockets (1) The specifications for the IP stack’s transport protocols do not include an Application Programmer’s Interface (API) A networking API called Sockets was distributed as part of the original UNIX –It has become the de-facto standard API and is now widely available on multiple OSes When an application creates a socket the OS returns a small integer descriptor that identifies the socket –The socket is similar to a file descriptor in UNIX 10

Sockets (2) An application creates a socket, and then invokes functions to adjust the socket details and to pass data through the socket –The descriptor is an argument to those other functions –The result it that each function call is relatively simple, but it takes a sequence of function calls to actually pass data The most commonly-used functions are shown on the following slide –Also, the helper functions gethostname, gethostbyaddr and gethostbyname allow an application user interface to use hostnames instead of IP addresses 11

Sockets (3) NameUsed ByDescription acceptserverAccept an incoming connection bindserverSpecify IP address and protocol port closeeitherTerminate communication connectclientConnect to a remote application (active open) getpeernameserverObtain client’s IP address getsocketoptserverObtain current options for a socket listenserverPrepare socket for use by a server (passive open) recveitherReceive incoming data or message recvmsgeitherReceive data (message transport) recvfromeitherReceive a message and sender’s address send (write)eitherSend outgoing data or message sendmsgeitherSend outgoing data (message transport) sendtoeitherSend outgoing message (variant of sendmsg) setsocketopteitherChange socket options shutdowneitherTerminate a connection (in one direction, i.e., half-close) socketeitherCreate a socket for use by the other functions 12

Sockets (4) The next slide shows the sequence of socket calls made by a typical client and server that use a stream connection –The client sends data first and the server waits to receive data The socket functions used to send and receive messages are more complicated than those used with the stream paradigm because more options are available –The connectionless, one-to-many behavior of the message transport is not as restrictive as the stream transport’s one-to-one connection 13

Sockets (4) 14 Illustration of stream socket function calls

Sockets (5) The socket API supports two different styles of servers –An iterative server iterates through each client one at a time This is why the API includes a queue for client connection requests –A concurrent server handles multiple clients at the same time The main server process has a listening socket When a connection request from a client arrives the main process creates a child process with its own socket that handles that connection while the main server process continues listening on its socket When the client is finished the child process closes its connection but the main server process continues to run 15

Sockets (6) The socket API adheres to the following rules: –The socket implementation uses a reference count mechanism to control each socket The socket exists as long as the reference count remains positive –When a socket is created its reference count is set to 1 –When a program creates an additional thread: The thread inherits a pointer to each open socket the program owns The reference count of each socket is incremented by 1 –When a thread calls close The system decrements the reference count for the socket If the reference count has reached zero, the socket is removed 16