Chapter 27 Socket API Interface The interface between an application program and the communication protocols in an operating system is known as the Application.

Slides:



Advertisements
Similar presentations
Sockets Programming Network API Socket Structures Socket Functions
Advertisements

Computer Net Lab/Praktikum Datenverarbeitung 2 1 Overview Sockets Sockets in C Sockets in Delphi.
Socket Programming Application Programming Interface.
Data Communications and Networking (Third Edition)
CS335 Networking & Network Administration Tuesday, May 25, 2010.
Socket Programming.
1 Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write)
Socket Addresses. Domains Internet domains –familiar with these Unix domains –for processes communicating on the same hosts –not sure of widespread use.
CSE/EE 461 Getting Started with Networking. Basic Concepts  A PROCESS is an executing program somewhere.  Eg, “./a.out”  A MESSAGE contains information.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
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.
TCP Socket Programming. r An abstract interface provided to the application programmer  File descriptor, allows apps to read/write to the network r Allows.
Network Programming Tutorial #9 CPSC 261. A socket is one end of a virtual communication channel Provides network connectivity to any other socket anywhere.
Socket Programming. Introduction Sockets are a protocol independent method of creating a connection between processes. Sockets can be either – Connection.
9/12/2015B.R1 Socket Abstraction and Interprocess Communication B.Ramamurthy CSE421.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
 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.
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.
Sockets API Overview Sockets with UDP Sockets with TCP Fast Sockets (Fast UDP) IP Multicasting.
 TCP (Transport Control Protocol) is a connection-oriented protocol that provides a reliable flow of data between two computers.  TCP/IP Stack Application.
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.
Remote Shell CS230 Project #4 Assigned : Due date :
Page 1 Jan 5, 1998 CMPN 369 CPSC441 Sockets Module Sockets Application Programming Interface (API)
The Pocket Guide to TCP/IP Sockets: C Version Michael J. Donahoo Kenneth L. Calvert.
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.
TELE202 Lecture 15 Socket programming 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (2) »Source: chapter 17 ¥This Lecture »Socket programming.
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)
CSE/EE 461 Getting Started with Networking. 2 Basic Concepts A PROCESS is an executing program somewhere. –Eg, “./a.out” A MESSAGE contains information.
Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.
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.
Socket Programming.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: HsinYu Ha.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Berkeley Socket Abstraction
Review: – Why layer architecture? – peer entities – Protocol and service interface – Connection-oriented/connectionless service – Reliable/unreliable service.
Socket Programming. Computer Science, FSU2 Interprocess Communication Within a single system – Pipes, FIFOs – Message Queues – Semaphores, Shared Memory.
UNIX Sockets Outline UNIX sockets CS 640.
Inter-Process Communication 9.1 Unix Sockets You may regard a socket as being a communication endpoint. –For two processes to communicate, both must create.
1 Dimension of Server Designs r Iterative vs Concurrent r Connection-oriented vs. connectionless r Stateful and stateless m Constrained by application.
Client-server communication Prof. Wenwen Li School of Geographical Sciences and Urban Planning 5644 Coor Hall
Socket Programming in C CS587x Lecture 3 Department of Computer Science Iowa State University.
1 K. Salah Application Layer Module K. Salah Network layer duties.
1 Socket Interface. 2 Client-Server Architecture The client is the one who speaks first Typical client-server situations  Client and server on the same.
1 Socket Interface. 2 Basic Sockets API Review Socket Library TCPUDP IP EthernetPPP ARP DHCP, Mail, WWW, TELNET, FTP... Network cardCom Layer 4 / Transport.
Distributed Systems1 Socket API  The socket API is an Interprocess Communication (IPC) programming interface originally provided as part of the Berkeley.
SOCKET PROGRAMMING Presented By : Divya Sharma.
Socket Abstraction and Interprocess Communication
Sockets and Beginning Network Programming
Socket Programming in C
Socket Interface 1 Introduction 11 Socket address formats 2 API 12 13
Interprocess Communication
Interacting With Protocol Software
Transport layer API: Socket Programming
Socket Abstraction and Interprocess Communication
27.
Starting TCP Connection – A High Level View
Socket Abstraction and Interprocess Communication
Socket Abstraction and Interprocess Communication
Interprocess Communication
Socket Abstraction and Interprocess Communication
Presentation transcript:

Chapter 27 Socket API Interface The interface between an application program and the communication protocols in an operating system is known as the Application Program Interface (API). Programmers build network-aware programs tailored to a particular set of APIs (eg. NetBIOS, WinSock, or Novell Sockets) – NetBIOS is Microsoft’s native network API – WinSock is a network API that runs on top of TCP/IP on PCs. The socket API is an industry standard used on many operating systems such as Windows 2000 Windows NT, and Sun Solaris.

Sockets An abstraction through which an application may send and receive data via network to a remote application. Sockets provide a generic access to interprocess communication Sockets provide a method of identifying a specific server process running on a machine that is accessible via an IP connection.

Socket Types Sockets come in different flavors, corresponding to different underlying protocol families and different stacks of protocols within a family. The main flavors of sockets in TCP/IP family are stream sockets and datagram sockets. Stream (connection-oriented) sockets use TCP as the end- to-end protocol providing a reliable byte-stream service. Datagram (connectionless) sockets use UDP, providing a best-effort service. A socket using TCP/IP protocol familty is uniquely identified by an IP address, a port number, and a end-to- end protocol (eg. TCP or UDP). Until a socket is bound to a port number, it cannot receive messages from a remote application.

Socket API function calls Socket Connect Bind Listen Accept Close Send Recv Getpeername Gethostname Gethostbyname Gethostbyaddress

Socket Function Call socket procedure creates a socket and returns an integer descriptor: – descriptor = socket(protofamily, connection_type, protocol) – eg. socketdescriptor = socket(PF_INET, SOCK_STREAM, TCP) – eg. socketdescriptor = socket(PF_INET, SOCK_DGRAM, UDP)

TCP Socket Structure Send Queue Receive Queue Protocol state (eg. Closed, listening, established, connecting) Local port number Local IP Remote port number Remote IP Socket descriptor

Close Function Call close procedure tells the system to terminate the use of a socket. – Close(socket) – where socket is the descriptor for the socket being closed

Bind Function Call bind procedure is used to associate a socket to a particular protocol port number bind(socket, localaddr,addrlen) – Where localaddr references a sockaddr_in data structure containing TCP port# and IP address of computer

Listen Function Call listen procedure is used by a server to instruct the operating system to place a socket in passive mode so that it can wait for contact from clients. Listen(socket, queuesize)

Accept Function Call accept procedure is used by connection oriented server to accept the next connection request by creating a new socket. The server’s original socket remains unchanged and is used to accept the next connection from a client. newsock=accept(socket, client_address, client_address_length) – Where client_address points to a sockaddr structure containing TCP port# and IP address of client computer – The new socket listens to the same port by forking a new process

Connect Function Call connect procedure is used by clients to establish a connection with a specific server. – When used with connection-oriented transport, connect establishes a transport connection to a specified server. – When used with connectionless transport, connect records the server’s address in the socket, allowing the client to send many messages to the same server without repeatedly specifying the server address with each message. connect (socket, server_IPaddress_and_port_number, server_address_length)

Send Function Call Send procedure is used by both clients and servers to send request and response via a connected socket. Send (socket, data, length, flags) – Where data is address of data buffer

Recv Function Call Recv procedure is used by both clients and servers to receive data sent by the other via a connected socket. Recv(socket, buffer, length, flags) – Where buffer contains data sent by other computer

Other function calls Getpeername procedure is used by server to obtain the address of the client that initiated the connection Gethostname procedure is used by both server and client to obtain name of of computer on which it is running. Gethostbyname procedure is usually used by clients to translate a hostname into an IP address. Gethostbyaddress is used by clients and servers to translate an IP address to a hostname.

Server and Client Socket Function Calls Server socket calls: – socket, bind, listen, accept, recv, getpeername, gethostbyaddr, send, close Client socket calls: – socket, connect, send, recv, close

Socket Function Calls socket bind listen accept send/recv close socket connect Recv/send close Server Client