 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.

Slides:



Advertisements
Similar presentations
2: Application Layer1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r Sockets are explicitly created, used, released by applications.
Advertisements

Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
Network Programming and Java Sockets
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.
Socket Programming.
1 Creating a network app Write programs that  run on different end systems and  communicate over a network.  e.g., Web: Web server software communicates.
1 Java Networking – Part I CS , Spring 2008/9.
2: Application Layer1 Data Communication and Networks Lecture 12 Java Sockets November 30, 2006.
1 Overview r Socket programming with TCP r Socket programming with UDP r Building a Web server.
Java Socket Support Presentation by: Lijun Yuan Course Number: cs616.
Internet and Intranet Protocols and Applications Lecture 4: Application Layer 3: Socket Programming February 8, 2005 Arthur Goldberg Computer Science Department.
Networking Overview February 2, /2/2004 Assignments Due – Homework 0 Due – Reading and Warmup questions Work on Homework 1.
Lecture 11 Java Socket Programming CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger and Joonbok Lee.
1 School of Computing Science Simon Fraser University CMPT 771/471: Internet Architecture and Protocols Socket Programming Instructor: Dr. Mohamed Hefeeda.
2: Application Layer1 Socket Programming. 2: Application Layer2 Socket-programming using TCP Socket: a door between application process and end- end-transport.
1 Network Layers Application Transport Network Data-Link Physical bits.
Protocols Rules for communicating between two entities (e.g., a client and a server) “A protocol definition specifies how distributed system elements interact.
2: Application Layer 1 Socket Programming Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley,
JAVA Socket Programming Joonbok Lee KAIST.
Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers.
2: Application Layer 1 Socket Programming TCP and UDP.
JAVA Socket Programming Source: by Joonbok Lee, KAIST, 2003.
Socket programming in C. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
CS1652 September 13th, 2012 The slides are adapted from the publisher’s material All material copyright J.F Kurose and K.W. Ross, All Rights.
2: Application Layer1 Chapter 2 Application Layer Computer Networking: A Top Down Approach Featuring the Internet, 2 nd edition. Jim Kurose, Keith Ross.
2: Application Layer1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
2: Application Layer1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
CS 3830 Day 11 Introduction : Application Layer 2 Server-client vs. P2P: example Client upload rate = u, F/u = 1 hour, u s = 10u, d min ≥ u s.
Discussion 2 Sockets Programming Applets TCP UDP HTTP Delay Estimation
Application Layer 2-1 ESERCITAZIONE SOCKET PROGRAMMING.
Chapter 2 Application Layer Computer Networking: A Top Down Approach, 5 th edition. Jim Kurose, Keith Ross Addison-Wesley, April A note on the use.
Winter 2002Suprakash Datta1 Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
-1- Georgia State UniversitySensorweb Research Laboratory CSC4220/6220 Computer Networks Dr. WenZhan Song Associate Professor, Computer Science.
1 CSCD 330 Network Programming Winter 2015 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 6 Application.
Vassil Roussev 2 A socket is the basic remote communication abstraction provided by the OS to processes. controlled by operating system.
Socket Programming Lee, Sooyong
 TCP (Transport Control Protocol) is a connection-oriented protocol that provides a reliable flow of data between two computers.  TCP/IP Stack Application.
RGEC MEERUT(IWT CS703) 1 Java Networking RGEC Meerut.
Socket Programming Tutorial. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
2: Application Layer1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
Chapter 2 Applications and Layered Architectures Sockets.
Java Sockets Programming
Java Socket programming. Socket programming with TCP.
2: Application Layer1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
2: Application Layer1 Socket programming Socket API Explicitly created, used, released by apps Client/server paradigm Two types of transport service via.
1 CSCD 330 Network Programming Spring 2014 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 7 Application.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm r two types of.
1 COMP 431 Internet Services & Protocols Client/Server Computing & Socket Programming Jasleen Kaur February 2, 2016.
1 CSCD 330 Network Programming Winter 2016 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 6 Application.
Socket programming in C. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 11 Omar Meqdadi Department of Computer Science and Software Engineering University.
1 Network Communications A Brief Introduction. 2 Network Communications.
Socket Programming original by Joonbok Lee KAIST heavily adapted by /Jens.
Socket Programming Socket Programming Overview
CS 1652 Jack Lange University of Pittsburgh
Socket programming with TCP
CSCD 330 Network Programming
Chapter 2: outline 2.1 principles of network applications
Socket programming - Java
Socket Programming Socket Programming Overview
Socket Programming.
CSCD 330 Network Programming
Java Socket Programming
Socket Programming 2: Application Layer.
Chapter 2: Application layer
Presentation transcript:

 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming interfaces (APIs) for applications using TCP/IP protocols.  Two types ▪ Stream socket : reliable two-way connected communication streams ▪ Datagram socket  Socket pair  Specified the two end points that uniquely identifies each TCP connection in an internet.  4-tuple: (client IP address, client port number, server IP address, server port number)

3 Port 0 Port 1 Port  Each host has 65,536 ports  Some ports are reserved for specific apps  20,21: FTP  22: ssh  80: HTTP  see RFC 1700 (about 2000 ports are reserved) A socket provides an interface to send data to/from the network through a port

 Implementation of a protocol standard defined in an RFC. (FTP, HTTP, SMTP…)  Conform to the rules dictated by the RFC.  Should use the port number associated with the protocol.  Proprietary client-server application.  A single developer( or team) creates both client and server program.  The developer has complete control.  Must be careful not to use one of the well-known port number defined in the RFCs. * well-known port number : managed by the Internet Assigned Numbers Authority(IANA)

The application developer has the ability to fix a few TCP parameters, such as maximum buffer and maximum segment sizes.

 Server  Welcoming socket ▪ Welcomes some initial contact from a client.  Connection socket ▪ Is created at initial contact of client. ▪ New socket that is dedicated to the particular client.  Client  Client socket ▪ Initiate a TCP connection to the server by creating a socket object. (Three-way handshake) ▪ Specify the address of the server process, namely, the IP address of the server and the port number of the process.

 socket (): Create a socket  bind(): bind a socket to a local IP address and port #  listen(): passively waiting for connections  connect(): initiating connection to another socket  accept(): accept a new connection  write(): write data to a socket  read(): read data from a socket  sendto(): send a datagram to another UDP socket  recvfrom(): read a datagram from a UDP socket  close() : close a socket

reliable byte stream transfer process TCP with buffers, variables socket controlled by application developer controlled by operating system process TCP with buffers, variables socket internet client server socket( ) bind( ) connect( ) socket( ) bind( ) listen( ) accept( ) send( ) recv( ) close( ) recv( ) send( ) TCP conn. request TCP ACK

Example client-server app:  client reads line from standard input, sends to server via socket  server reads line from socket  server converts line to uppercase, sends back to client  client reads, prints modified line from socket Input stream: sequence of bytes into process output stream: sequence of bytes out of process Client process client TCP socket

wait for incoming connection request connectionSocket = welcomeSocket.accept() create socket, port= x, for incoming request: welcomeSocket = ServerSocket() create socket, connect to hostid, port= x clientSocket = Socket() close connectionSocket read reply from clientSocket close clientSocket Server (running on host id ) Client send request using clientSocket read request from connectionSocket write reply to connectionSocket TCP connection setup

 The package java.net provides support for sockets programming (and more).  Typically you import everything defined in this package with: import java.net.*; 12

InetAddress Socket ServerSocket DatagramSocket DatagramPacket 13

 static methods you can use to create new InetAddress objects.  getByName(String host)  getAllByName(String host)  getLocalHost() InetAddress x = InetAddress.getByName( “  Throws UnknownHostException 14

try { InetAddress a = InetAddress.getByName(hostname); System.out.println(hostname + ":" + a.getHostAddress()); } catch (UnknownHostException e) { System.out.println("No address found for " + hostname); } try { InetAddress a = InetAddress.getByName(hostname); System.out.println(hostname + ":" + a.getHostAddress()); } catch (UnknownHostException e) { System.out.println("No address found for " + hostname); }

 Corresponds to active TCP sockets only!  client sockets  socket returned by accept();  Passive sockets are supported by a different class:  ServerSocket  UDP sockets are supported by  DatagramSocket 16

 UDP  Connectionless and unreliable service.  There isn’t an initial handshaking phase.  Doesn’t have a pipe.  transmitted data may be received out of order, or lost  Socket Programming with UDP  No need for a welcoming socket.  No streams are attached to the sockets.  the sending hosts creates “packets” by attaching the IP destination address and port number to each batch of bytes.  The receiving process must unravel to received packet to obtain the packet’s information bytes.

Output: sends packet (TCP sent “byte stream”) Input: receives packet (TCP received “byte stream”) Client process client UDP socket

 Servers need to handle a new connection request while processing previous requests.  Most TCP servers are designed to be concurrent.  When a new connection request arrives at a server, the server accepts and invokes a new process to handle the new client.