School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP 112 2016.

Slides:



Advertisements
Similar presentations
Socket Programming ENTERPRISE JAVA. 2 Content  Sockets  Streams  Threads  Readings.
Advertisements

Multiplexing/Demux. CPSC Transport Layer 3-2 Multiplexing/demultiplexing application transport network link physical P1 application transport network.
Socket Programming By Ratnakar Kamath. What Is a Socket? Server has a socket bound to a specific port number. Client makes a connection request. Server.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
Network Programming CS3250. References Core Java, Vol. II, Chapter 3. Book examples are available from
System Programming Practical session 10 Java sockets.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L22 (Chapter 25) Networking.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
Socket Communication Sockets provide an abstraction of two-point communication The two sides only read/write without concern for how data is translated.
Networking with Java. Basic Concepts A Network exists when two or more computers are connected such that they can communicate data back and forth. There.
CEG3185 Tutorial 4 Prepared by Zhenxia Zhang Revised by Jiying Zhao (2015w)
19-Aug-15 About the Chat program. 2 Constraints You can't have two programs (or two copies of the same program) listen to the same port on the same machine.
Socket Programming in Java -First Step of Network Programming-
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
SOCKET PROGRAMMING. Client/Server Communication At a basic level, network-based systems consist of a server, client, and a media for communication as.
TCP/IP protocols Communication over Internet is mostly TCP/IP (Transmission Control Protocol over Internet Protocol) TCP/IP "stack" is software which allows.
NET0183 Networks and Communications Lecture 31 The Socket API 8/25/20091 NET0183 Networks and Communications by Dr Andy Brooks Lecture powerpoints from.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 12 Communicating over.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Networking COMP # 21.
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
Vassil Roussev 2 A socket is the basic remote communication abstraction provided by the OS to processes. controlled by operating system.
Mark Fontenot CSE Honors Principles of Computer Science I Note Set 11.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
 TCP (Transport Control Protocol) is a connection-oriented protocol that provides a reliable flow of data between two computers.  TCP/IP Stack Application.
Practicum: - Client-Server Computing in Java Fundamental Data Structures and Algorithms Margaret Reid-Miller 13 April 2004.
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.
Object Oriented Programming in Java Lecture 16. Networking in Java Concepts Technicalities in java.
Lecture 9 Network programming. Manipulating URLs URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on the Internet.
Li Tak Sing COMPS311F. Case study: consumers and producers A fixed size buffer which can hold at most certain integers. A number of producers which generate.
© Lethbridge/Laganière 2005 Chap. 3: Basing Development on Reusable Technology The Client-Server Architecture A distributed system is a system in.
1 Chapter 28 Networking. 2 Objectives F To comprehend socket-based communication in Java (§28.2). F To understand client/server computing (§28.2). F To.
1 Network Programming and Java Sockets. 2 Network Request Result a client, a server, and network Client Server Client machine Server machine Elements.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Networking COMP # 22.
Networks Sockets and Streams. TCP/IP in action server ports …65535 lower port numbers ( ) are reserved port echo7 time13 ftp20 telnet23.
 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(1/11) Java Sockets and Simple Networking Joel Adams and Jeremy Frens.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Networking and Concurrency COMP.
CS390- Unix Programming Environment CS 390 Unix Programming Environment Java Socket Programming.
Networking Terminology: ISP (Internet service provider) – dialup, dsl, cable LAN (local area network) IP (internet protocol) address, eg
Java Sockets Tutorial Rahul Malik Nov 12, 2005.
VII. Sockets. 1. What is a Socket? A socket is one end-point of a two-way communication link between two programs running on the network. Socket classes.
Java Server Programming Web Interface for Java Programs.
Client/Server Socket Programming Project
Part 4: Network Applications Client-server interaction, example applications.
 Socket class ◦ provides a rich set of methods and properties for network communications. The Socket class allows you to perform both synchronous and.
TCP/IP Protocol Stack IP Device Drivers TCPUDP Application Sockets (Gate to network) TCP: –Establish connection –Maintain connection during the communication.
Prepared by Dr. Jiying Zhao University of Ottawa Canada.
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
1 COMP 431 Internet Services & Protocols Client/Server Computing & Socket Programming Jasleen Kaur February 2, 2016.
1 Lecture 9: Network programming. 2 Manipulating URLs URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Network Programming: Servers. Agenda l Steps for creating a server Create a ServerSocket object Create a Socket object from ServerSocket Create an input.
Networking Code CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Java API for distributed computing.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW IRC, parsing, protocols COMP # 25.
Generic Connection Framework Connection FileConnectionSocketConnectionHTTPConnection InputConnection OutputConnection StreamConnection.
SOCKET PROGRAMMING WITH JAVA By Collin Donaldson.
Java 13. Networking public class SumTest {
Echo Networking COMP
Network Programming in Java CS 1111 Ryan Layer May 3, 2010
Lecture 21 Sockets 1 (Not in D&D) Date.
Networking COMP
Networks and Client/Server Applications
Socket Programming Cal Poly Pomona Young CS380.
PRESENTED To: Sir Abid………. PRESENTED BY: Insharah khan………. SUBJECT:
Starting TCP Connection – A High Level View
CS18000: Problem Solving and Object-Oriented Programming
Presentation transcript:

School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP

COMP112 22: 2 Menu Review Networking Protocol stack & abstraction Scocket as point to point “wire” Sever Client Echo Server Client Code Comunication Portocol Admin

COMP112 22: 3 Getting a Socket Connection requires each computer to set up a socket connected to the other How do you specify where you want the connection to go to? Which program running on which computer is going to serve you a web page? Which program goes first? Need a connection at the other end in order to set up the one at this end!

COMP112 22: 4 Addressing a connection Two parts to the address: host computer: IP address, (can be specified by Host name) “port” (an integer) Each computer on the network must have an IP address (“debretts.ecs.vuw.ac.nz”) Operating system provides a set of “ports” that connections can be associated with. Many programs have a standard port number. Application can specify a remote host and a port. Can hope the program at the other end will listen 1 2 : 80 : : 80 : 6667

COMP112 22: 5 Who goes first? If application requests connection to a port on a remote host, but there is no application on that port at the remote host that will respond to the request, connection will fail. Need to have an application on remote host listening to the port before a client requests connection: Client – Server model: If host provides some service: Server application runs on a remote host Server application listens on a known port Client application can request a connection to host : port Server application will hear, and can accept the request Operating systems will set up a new socket on each end with a connection between them.

COMP112 22: 6 Addressing a connection Client 1 2 : 80 : 6667 Server 1 2 : 80 : 6667 Listening on port 6667 Request connection to port 6667 on Server via port xx Application accepts connection OS creates socket connected to port xx on Client OS creates socket connected to port 6667 on Server xx Application is still listening!

COMP112 22: 7 Echo Service - Very Simple The Echo Server provides a Service to the Client Echo server will echo back any message sent to it: ClientServer Client Hello there. Are you listening Echo: Hello there. Are you listening I want help Echo: I want help

COMP112 22: 8 Connecting Client and Server try { ServerSocket serverSocket = new ServerSocket(PORT); while (true) { Socket socket = serverSocket.accept(); … set up Scanner and PrintStream and communicate via socket } } catch (IOException e){System.out.println("Failed connection "+ e); } try { Socket socket = new Socket("irc.ecs.vuw.ac.nz", PORT); …set up Scanner and PrintStream and communicate via socket } catch (IOException e){System.out.println("Failed connection "+ e); } Server port Server Client

COMP112 22: 9 Echo Client. public static final String SERVER = "localhost"; public static final int PORT = 6667; public static void main(String[ ] args) { try { Socket socket = new Socket(SERVER, PORT); Scanner input = new Scanner(socket.getInputStream()); PrintStream output = new PrintStream(socket.getOutputStream(), true); while (true) { String toSend = UI.askString(">"); output.println(toSend); if (toSend.equals("QUIT")){ UI.quit(); } String rcvd = input.nextLine(); UI.println(rcvd); } }catch(IOException e){UI.println("IO failure "+ e);} } Waits For ever

COMP112 22: 10 Client 1.Wait for user input 2.Send to server 3.Wait for echo 4.Display to user Server 1.Wait for client 2.Send echo This Service might be very simple but: Switching the operation order and the system fails to function. Client and Server C 1 Wait for user input 2 send to server 3 Wait for echo 4 display to user S 1 wait for client 2 send echo

COMP112 22: 11 What dose the server look like if there are two clients Two Clients and what Server? B Wait input send to server Wait echo Display S A Wait input send to server Wait echo Display Receive from AReceive from B Send to A Send to B Receive from A Receive from B Send to A Send to B

COMP112 22: 12 One server many clients What are the requirements that the server must satisfy? 1.A always goes before B 2.B always goes before A 3.Any order including only A and never B. 4.…… How do you write code that satisfies these requirements?

COMP112 22: 13 Your IRC client Will be larger than the echo client Will be more than just a main method Needs a richer interface (buttons, etc) Needs to deal with messages better. Needs a more complex logging in. BUT The basic ideas are mostly present in the echo client EXCEPT for any order response between: 1.User inputting a message 2.IRC sending you a message Coded as asynchronous send and receive.