© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.

Slides:



Advertisements
Similar presentations
1 Communication in Distributed Systems REKs adaptation of Tanenbaums Distributed Systems Chapter 2.
Advertisements

1 Computer Networks and Internets, 5e By Douglas E. Comer Lecture PowerPoints Adapted from the notes By Lami Kaya, © 2009 Pearson Education.
Tam Vu Remote Procedure Call CISC 879 – Spring 03 Tam Vu March 06, 03.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
28.2 Functionality Application Software Provides Applications supply the high-level services that user access, and determine how users perceive the capabilities.
Slide 1 Client / Server Paradigm. Slide 2 Outline: Client / Server Paradigm Client / Server Model of Interaction Server Design Issues C/ S Points of Interaction.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets, 5e By Douglas E. Comer Lecture PowerPoints.
CS335 Networking & Network Administration Tuesday, May 25, 2010.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write) Receive.
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets, 5e By Douglas E. Comer Lecture PowerPoints.
Socket Programming.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 17 Introduction to the Application.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
1 Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write)
CS3771 Today: network programming with sockets  Previous class: network structures, protocols  Next: network programming Sockets (low-level API) TODAY!
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L22 (Chapter 25) Networking.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
NFS. The Sun Network File System (NFS) An implementation and a specification of a software system for accessing remote files across LANs. The implementation.
1 Computer Networks and Internets, 5e By Douglas E. Comer Lecture PowerPoints Adapted from the notes By Lami Kaya, © 2009 Pearson Education.
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.
Chapter 17 Networking Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.
9/12/2015B.R1 Socket Abstraction and Interprocess Communication B.Ramamurthy CSE421.
NET0183 Networks and Communications Lecture 31 The Socket API 8/25/20091 NET0183 Networks and Communications by Dr Andy Brooks Lecture powerpoints from.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
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.
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets, 5e By Douglas E. Comer Lecture PowerPoints.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
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.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Distributed Computing A Programmer’s Perspective.
CE Operating Systems Lecture 13 Linux/Unix interprocess communication.
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets, 5e By Douglas E. Comer Lecture PowerPoints.
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.
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets, 5e By Douglas E. Comer Lecture PowerPoints.
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.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
File Transfer And Access (FTP, TFTP, NFS). Remote File Access, Transfer and Storage Networks For different goals variety of approaches to remote file.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 5.
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets, 5e By Douglas E. Comer Lecture PowerPoints.
1 Network Communications A Brief Introduction. 2 Network Communications.
Sockets Intro to Network Programming. Before the internet... Early computers were entirely isolated No Internet No network No model No external communications.
Lecture PowerPoints By Lami Kaya,
Chapter 3 Internet Applications and Network Programming
Computer Networks and Internets, 5e By Douglas E. Comer
Socket Interface 1 Introduction 11 Socket address formats 2 API 12 13
Chapter 3: Windows7 Part 4.
Interacting With Protocol Software
Socket Abstraction and Interprocess Communication
Chapter 15: File System Internals
Chapter 3 Socket API © Bobby Hoggard, Department of Computer Science, East Carolina University These slides may not be used or duplicated without permission.
Presentation transcript:

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas E. Comer Lecture PowerPoints By Lami Kaya,

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.2 Chapter 29 The Socket Interface

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.3 Topics Covered 29.1 Introduction 29.2 Application Program Interface 29.3 The Socket API 29.4 Sockets And Socket Libraries 29.5 Socket Communication And UNIX I/O 29.6 Sockets, Descriptors, And Network I/O 29.7 Parameters And The Socket API

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.4 Topics Covered (cont.) 29.8 Procedures That Implement The Socket API – The Socket Procedure – The Close Procedure – The Bind Procedure – The Listen Procedure – The Accept Procedure – The Connect Procedure – The Send, Sendto, And Sendmsg Procedures – The Recv, Recvfrom, And Recvmsg Procedures 29.9 Read And Write With Sockets Other Socket Procedures Sockets, Threads, And Inheritance

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved Introduction The chapter presents the motivation for using client-server discusses concepts such as concurrency shows how clients/servers use transport protocols to communicate provides additional details about client-server interaction by explaining the interface between an application and protocol SW considers how an application uses protocol SW to communicate explains an example set of procedures –that an application uses to become a client or a server, –to contact a remote destination, –or to transfer data

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved Application Program Interface An application must specify some details for communication An application uses SW tools is known as an –Application Program Interface (API) An API defines a set of operations that an application can perform when interacting with protocol SW. Most programming systems define an API –by listing a set of procedures available to applications –the arguments that each procedure expects –and the data types Usually, an API contains a separate procedure for each logical function

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved The Socket API Communication protocols do not usually specify an API that applications use to interact with the protocols –Instead, the protocols specify the general operations that should be provided –and allow each OS to define the specific API an application uses to perform the operations OS designers to choose an API, many have adopted the –“socket API” or simply “socket” The socket API is available for many OS

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved Sockets And Socket Libraries (1) From an application programmer's point of view –a “socket library” provides the same semantics as an implementation of sockets in the OS –the program calls socket procedures, which are either supplied by OS procedures or library routines. In practice, socket libraries are seldom perfect –and minor differences sometimes occur between the standard implementation of a socket API and a socket library

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved Sockets And Socket Libraries (2) Despite apparent similarities, socket libraries have a completely different implementation than a native socket API supplied by an OS The code for socket library procedures is linked into the application program and resides in the application's address space When an application calls a procedure from the socket library –control passes to the library routine which, in turn, makes one or more calls to the underlying OS functions to achieve the desired effect Functions supplied by the underlying OS need not resemble the socket API at all Routines in the socket library hide the native OS from the application and present only a socket interface

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved Socket Communication And UNIX I/O Sockets are integrated with I/O –an application communicates through a socket similar to the way the application transfers data to or from a file –understanding sockets requires one to understand UNIX I/O UNIX uses an open-read-write-close paradigm for all I/O –the name is derived from the basic I/O operations that apply to both devices and files For example, –an application must first call “open” to prepare a file for access –The application then calls “read” or “write” to retrieve data from the file or store data in the file –Finally, the application calls “close” to specify that it has finished using the file

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved Sockets, Descriptors, And Network I/O (1) Before an application can use protocols to communicate –The application must request the OS to create a socket that will be used for communication –The system returns a small integer “descriptor” that identifies the socket –The application then passes the descriptor as an argument when it calls procedures to transfer data across the NW the application does not need to specify details about the remote destination each time it transfers data The OS provides a single set of descriptors for files, devices, interprocess communication (IPC) UNIX provides a pipe mechanism for IPC

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved Sockets, Descriptors, And Network I/O (2) An application can use the same procedure to send data to –another program, a file, or across a NW The descriptor represents an object, and the “write” procedure represents a method applied to that object –The underlying object determines how the method is applied The chief advantage of an integrated system lies in its flexibility –a single application can be written that transfers data to an arbitrary location If the application is given a descriptor that corresponds to a device –The application sends data to the device If the application is given a descriptor that corresponds to a file –the application stores data in the file. If the application is given a descriptor that corresponds to a socket –the application sends data across an internet to a remote machine

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved Parameters And The Socket API Socket programming differs from conventional I/O –because an application must specify many details to use a socket For example, –an application must choose a particular transport protocol, –provide the protocol address of a remote machine, –and specify whether the application is a client or a server To accommodate all the details –each socket has many parameters and options –an application can supply values for each How should options and parameters be represented in an API? –To avoid having a single socket function with separate parameters for each option, designers of the socket API chose to define many functions. –An application creates a socket and then invokes functions to specify in detail The advantage is that most functions have few parameters The disadvantage is that, we must remember to call multiple functions

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved Procedures That Implement The Socket API Please refer to following sub-sections for procedures being used and parameters being passed: – The Socket Procedure – The Close Procedure – The Bind Procedure – The Listen Procedure – The Accept Procedure – The Connect Procedure – The Send, Sendto, And Sendmsg Procedures – The Recv, Recvfrom, And Recvmsg Procedures

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved Read And Write With Sockets Sockets allow applications to use read and write Like send and recv, read and write do not have arguments that permit the caller to specify a destination Instead, read and write each have three arguments: –a socket descriptor –the location of a buffer in memory used to store the data –and the length of the memory buffer The chief advantage of using read and write is generality –an application program can be created that transfers data to or from a descriptor without knowing whether the descriptor corresponds to a file or a socket thus, a programmer can use a file on a local disk to test a client or server before attempting to communicate across a NW The chief disadvantage is that a socket library implementation may introduce additional overhead in the file I/O

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved Other Socket Procedures The socket API contains other useful procedures For example, –after a server calls procedure accept to accept an incoming connection request, the server can call procedure “getpeername” to obtain the complete address of the remote client that initiated the connection –A client or server can also call “gethostname” to obtain information about the computer on which it is running Two general-purpose procedures are used to set socket options or obtain a list of current values, an application calls procedure –“setsockopt” to store values in socket options –“getsockopt” to obtain current option values –Options are used mainly to handle special cases

© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved Sockets, Threads, And Inheritance Because many servers are concurrent, the socket API is designed to work with concurrent programs Although the details depend on the underlying OS implementations of the socket API adhere to the following principle: –Each new thread that is created inherits a copy of all open sockets from the thread that created it