Beyond HTTP Up to this point we have been dealing with software tools that run on browsers and communicate to a server that generates files that can be.

Slides:



Advertisements
Similar presentations
Java Network Programming Vishnuvardhan.M. Dept. of Computer Science - SSBN Java Overview Object-oriented Developed with the network in mind Built-in exception.
Advertisements

Network Programming Chapter 11 Lecture 6. Networks.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
Basic Socket Programming with Java. What is a socket?  Generally refers to a stream connecting processes running in different address spaces (across.
Advanced Java Class Network Programming. Network Protocols Overview Levels of Abstraction –HTTP protocol: spoken by Web Servers and Web Clients –TCP/IP:
Socket Programming.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
1 Java Networking – Part I CS , Spring 2008/9.
WECPP1 Java networking Jim Briggs based on notes by Amanda Peart based on Bell & Parr's bonus chapter
CS3771 Today: network programming with sockets  Previous class: network structures, protocols  Next: network programming Sockets (low-level API) TODAY!
Client Server Model The client machine (or the client process) makes the request for some resource or service, and the server machine (the server process)
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L22 (Chapter 25) Networking.
© Lethbridge/Laganière 2001 Chap. 3: Basing Development on Reusable Technology 1 Let’s get started. Let’s start by selecting an architecture from among.
Networking Support In Java Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
CEG3185 Tutorial 4 Prepared by Zhenxia Zhang Revised by Jiying Zhao (2015w)
TCP Sockets Reliable Communication. TCP As mentioned before, TCP sits on top of other layers (IP, hardware) and implements Reliability In-order delivery.
Socket Programming in Java -First Step of Network Programming-
Socket Programming -What is it ? -Why bother ?. Basic Interface for programming networks at transport level It is communication end point Used for inter.
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  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
Vassil Roussev 2 A socket is the basic remote communication abstraction provided by the OS to processes. controlled by operating system.
 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.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
© 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.
UDP User Datagram Protocol. User Datagram Protocol (UDP) UDP is the protocol available to network programmers who wish to send datagrams UDP datagrams.
1 Network Programming and Java Sockets. 2 Network Request Result a client, a server, and network Client Server Client machine Server machine Elements.
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
ECEN “Internet Protocols and Modeling”, Spring 2012 Course Materials: Papers, Reference Texts: Bertsekas/Gallager, Stuber, Stallings, etc Class.
CS 158A1 1.4 Implementing Network Software Phenomenal success of the Internet: – Computer # connected doubled every year since 1981, now approaching 200.
Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
TCP/IP Protocol Stack IP Device Drivers TCPUDP Application Sockets (Gate to network) TCP: –Establish connection –Maintain connection during the communication.
1 Netprog 2002 TCP/IP UDP/IP in Java Based on Java Network Programming and Distributed Computing.
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.
Socket Programming in Java -First Step of Network Programming-
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.
Java Networking I IS Outline  Quiz #3  Network architecture  Protocols  Sockets  Server Sockets  Multi-threaded Servers.
SOCKET PROGRAMMING WITH JAVA By Collin Donaldson.
1 Network Communications A Brief Introduction. 2 Network Communications.
Network Programming. These days almost all devices.
Distributed Systems1 Socket API  The socket API is an Interprocess Communication (IPC) programming interface originally provided as part of the Berkeley.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 33 Networking.
Prepared by: Dr. Abdallah Mohamed, AOU-KW Unit9: Internet programming 1.
Socket Programming Ameera Almasoud
Application Layer Functionality and Protocols Abdul Hadi Alaidi
Object-Orientated Analysis, Design and Programming
Chapter 9: Transport Layer
Networking Based Applications
Client-Server Communication
Instructor Materials Chapter 9: Transport Layer
Sockets and Beginning Network Programming
Networking COMP
MCA – 405 Elective –I (A) Java Programming & Technology
Network Programming Introduction
Client-Server Interaction
Java Socket Programming and Java RMI CS
Lecture 11 Socket Programming.
Process-to-Process Delivery:
Starting TCP Connection – A High Level View
Process-to-Process Delivery: UDP, TCP
Computer Networks Protocols
Java Socket Programming and Java RMI CSE 291
Based on Java Network Programming and Distributed Computing
Review Communication via paired sockets, one local and one remote
Presentation transcript:

Beyond HTTP Up to this point we have been dealing with software tools that run on browsers and communicate to a server that generates files that can be interpreted by the browser What HTTP “is”: it forms elements (.html. .xml) with programs (processes) running on the server (e.g. java) and on clients (e.g. javaScript), cookies). HTTP is a stateless protocol: the browser makes a simple request, the server responds and the connection is immediately closed. Once the connection is broken, the server forgets all about the request and moves to handle the next request. May wish to establish more “persistent” connections between Browser and Server (e.g. TCP (Transmission Control Protocol, 100% reliability, echos back), UTP (User Datagram Protocol, just throws it out there)) Aperil 12, 2006 Week 9

Assignment 5: Beyond HTTP Setting up persistent connections Create a system that accesses departure gate information from two (2) airlines GateKeeper.java controls the flow of the app GateListener.java listens toa UDP port for gate information GateInformationBoard.java displays the gate info Each airline maintains their own departure gate information on their own computers. carmonAir’s machine is named calabolg vanderFly’s machine is named balmung Each is listening on port 8189 for registration information which includes machine name and port number that directs the outbound UDP gate data Your machine needs to be listening for those messages at that port Aperil 12, 2006 Week 9

Machines in Assignment 5 calabolg Registration TCP port 8189 yourMachine 8189 GateInfo UDP 8190 Register & Accept 8189 8191 Registration TCP port 8189 GateInfo UDP 8189 balmung Aperil 12, 2006 Week 9

Using Sockets to implement a more persistent Client –Server connection RMI (Remote Method Invocation): lets you easily access methods in remote java objects including the ability to send and receive general java objects. The java DataBase Connectivity (JDBC) API provides access to a wide variety of relational databases using a standard interface Aperil 12, 2006 Week 9

Implementing a Client: Create a Socket object Create an output stream that can be used to send information to the Socket Create an input stream to read the response from the server Do I/O with the input and output streams Close the socket when done! Aperil 12, 2006 Week 9

Create a Socket object A socket is an object corresponding to a network connection A client connects to an existing server that is listening on a numbered network “port” for a connection Standard way to making a socket connection is to supply a host name and a port # as follows: Socket client = new Socket (“hostname”, portNum); If you have an IP address (e.g. 198.4.155.21), then you can turn it into an InetAddress object by calling: get ByName: InetAddress address = InetAddress.getByName (“IPAddress”); Socket client = new Socket (address, portNumber); This is then a connection oriented socket (TCP) In Java 1.1: Socket client = new DatagramSocket (“hostname”, portNum); Aperil 12, 2006 Week 9

Create an output stream that can be used to send info to the socket Can use any of a variety of OutputStream processes available for files In Java 1.0 PrintStream of System.out PrintStream out = new PrintStream (client.getOutputStream()); Aperil 12, 2006 Week 9

Create an inputStream (read data from server) Use DataInoutStream DataInputStream in = new DataInputStream (client.getInputStream()); The input stream usually needs to be buffered: BufferedInputStream buffered = new BufferedInputStream (client.getInputStream()); DataInputStream in = new DataInputStream (buffered); Aperil 12, 2006 Week 9

Comments A simple email client would send something to a server but not read anything back. In this case, since you do not want to read anything back, then you don’t need an inputStream (step 3) In other cases you may want to read data from a server w/o sending anything first. e.g. a network “clock” is simply pumping out the time at a certain port. You then don’t need to create an output stream (step 2) If you do want to do I/O with input and output streams then realize: readChar and readLine are “blocking” methods: they do not return until data is avalable readFully “blocks” until all of the data is available Need to convert byte arrays into strings; String fullstring = new String (byteArray.o); String partialString = new String(byteArray.o, tartIndex, numBytes); Aperil 12, 2006 Week 9

Close Socket when done!! Client.clos(); Aperil 12, 2006 Week 9

Aperil 12, 2006 Week 9