Network Programming Introduction

Slides:



Advertisements
Similar presentations
Prepared By E. Musa Alyaman1 URLs, InetAddresses, and URLConnections Chapter 9.
Advertisements

Socket Programming.
User Datagram Protocol. Introduction UDP is a connectionless transport protocol, i.e. it doesn't guarantee either packet delivery or that packets arrive.
1 Java Networking – Part I CS , Spring 2008/9.
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
Networking Support In Java 2 Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Internet Programming In Java. References Java.sun.com Java552 Many of the programs shown.
COMP1681 / SE15 Introduction to Programming
CIS – Spring Instructors: Geoffrey Fox, Bryan Carpenter Computational Science and.
Lecture 11 Java Socket Programming CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger and Joonbok Lee.
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.
Networking Support In Java 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
13-Jul-15 Sockets and URLs. 2 Sockets A socket is a low-level software device for connecting two computers together Sockets can also be used to connect.
Networking java.net package, which provides support for networking. Its creators have called Java “programming for the Internet.” Socket :- A network socket.
Java Networking.
JAVA Socket Programming Source: by Joonbok Lee, KAIST, 2003.
Socket Programming -What is it ? -Why bother ?. Basic Interface for programming networks at transport level It is communication end point Used for inter.
Babak Esfandiari (based on slides by Qusay Mahmoud)
CS4273: Distributed System Technologies and Programming I Lecture 5: Java Socket Programming.
SOCKET PROGRAMMING. Client/Server Communication At a basic level, network-based systems consist of a server, client, and a media for communication as.
Computer Networks  Network - A system of computers interconnected in order to share information.  Data transmission - consists of sending and receiving.
Multicast Sockets What is a multicast socket?
Application Protocols: HTTP CSNB534 Semester 2, 2007/2008 Asma Shakil.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
VIII. UDP Datagrams and Sockets. The User Datagram Protocol (UDP) is an alternative protocol for sending data over IP that is very quick, but not reliable:
CS 424/524: Introduction to Java Programming Lecture 25 Spring 2002 Department of Computer Science University of Alabama Joel Jones.
DBI Representation and Management of Data on the Internet.
RGEC MEERUT(IWT CS703) 1 Java Networking RGEC Meerut.
1 A TCP/IP Application Programming Perspective Chris Greenhalgh G53ACC.
Object Oriented Programming in Java Lecture 16. Networking in Java Concepts Technicalities in java.
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.
Java Sockets Programming
Java Socket programming. Socket programming with TCP.
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
What is a Network? Computer network Computer network a set of computers using common protocols to communicate over connecting transmission media. a set.
NETWORK PROGRAMMING.
Java Networking. java.net package provides support of networking. Its creators have called Java "programming for the Internet." What makes Java a good.
Networking Java (2/3)
Java IO. Why IO ? Without I/O, your program is a closed box. Without I/O, your program is a closed box. I/O gives your Java program access to your hard.
By Vivek Dimri. Basic Concepts on Networking IP Address – Protocol – Ports – The Client/Server Paradigm – Sockets The Java Networking Package – The InetAddress.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Inetaddress Class When establishing a connection across the Internet, addresses.
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
Java Programming II Java Network (I) Java Programming II.
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.
UDP User Datagram Protocol. About the UDP A commonly used transport protocol Does not guarantee either packet delivery or order The packets may travel.
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
Java How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Advance Computer Programming Networking Basics – explores the java.net package which provides support for networking. – Also Called “programming for the.
Network Programming. These days almost all devices.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 33 Networking.
Network Programming Communication between processes Many approaches:
Java.net CS-328 Dick Steflik.
Secure Sockets SSL (Secure Sockets Layer) is a standard security technology for establishing an encrypted link between a server and a client—typically.
Source: Java Sockets Source:
Topic: Network programming
Network Programming Introduction
MCA – 405 Elective –I (A) Java Programming & Technology
NETWORK PROGRAMMING CNET 441
Network Programming Introduction
Sockets and URLs 17-Sep-18.
Java Network Programming
Sockets and URLs 13-Nov-18.
URL in Java C343 Lab (Week 13).
Networking.
Sockets and URLs 3-Dec-18.
Networking.
NETWORK PROGRAMMING CNET 441
Java Socket Programming
Presentation transcript:

Network Programming Introduction Based on Classes in the java.net package 9/13/2018 V.B.Sanghavi

JAVA Networking API series of layered abstractions basic networking capabilities are split between the java.net and the java.io defining custom protocols, using existing protocols, or building a higher-level API on top of the basic services 9/13/2018 V.B.Sanghavi

Low Level API Addresses, which are networking identifiers, like IP addresses. Sockets, which are basic bidirectional data communication mechanisms. Interfaces, which describe network interfaces. 9/13/2018 V.B.Sanghavi

High Level API URIs, which represent Universal Resource Identifiers. URLs, which represent Universal Resource Locators. Connections, which represents connections to the resource pointed to by URLs. 9/13/2018 V.B.Sanghavi

Network Terminology IP Address Connection-oriented (TCP) and connectionless protocol (UDP) Protocol Socket –allows a single comp. to serve diff.clients at once. Port Number –numbered socket Domain Naming Service(DNS) 9/13/2018 V.B.Sanghavi

Client-server Architecture 9/13/2018 V.B.Sanghavi

Networking Classes InetAddress Socket ServerSocket URL URLConnection DatagramSocket DatagramPacket 9/13/2018 V.B.Sanghavi

InetAddress Encapsulates the Numerical IP address and domain name for that address. Interact with this class by hostname as it is more convenient. Can handle IPv4 and IPv6 addresses. 9/13/2018 V.B.Sanghavi

Factory Methods static InetAddress getLocalHost() throws UnknownHostException static InetAddress getByName(String hostname) throws UnknownHostException Static InetAddress[] getAllByName() throws UnknownHostException 9/13/2018 V.B.Sanghavi

static InetAddress getByAddress() throws UnknownHostException 9/13/2018 V.B.Sanghavi

Instance Methods Boolean equals(Object o) Byte[] getAddress() String getHostAddress() String getHostName() Boolean isMulticastAddress() String toString() 9/13/2018 V.B.Sanghavi

Socket Programming for communication between the machines. The client in socket programming must know two information: IP address Port number 9/13/2018 V.B.Sanghavi

Socket class endpoint for communications between the machines. create a socket to connect to a server sockets and initiate protocol exchange. Constructor Socket (String host, int port) Socket ( InetAddress ip, int port) program 9/13/2018 V.B.Sanghavi

- inetAddress getInetAddress() int getPort() int getLocalPort() Methods : - inetAddress getInetAddress() int getPort() int getLocalPort() 9/13/2018 V.B.Sanghavi

- public InputStream getInputStream() Socket class Methods: - public InputStream getInputStream() - public OutputStream getOutputStream() - void close() 9/13/2018 V.B.Sanghavi

ServerSocket class to create a server socket that listen for local or remote client program. Constructor: ServerSocket (int port) ServerSocket (int port, int maxqueue) ServerSocket ( int port, int maxqueue, InetAddress i) program 9/13/2018 V.B.Sanghavi

- public Socket accept() - public InputStream getInputStream() Methods: - public Socket accept() - public InputStream getInputStream() - public OutputStream getOutputStream() - void close() 9/13/2018 V.B.Sanghavi

URL class represents a URL (Uniform Resource Locator) to uniquely identify or address info. On the internet. URLs can point to files, Web sites, ftp sites, newsgroups, email addresses, and other resources. 9/13/2018 V.B.Sanghavi

Format of URL http://www.javatpoint.com : 8080/abc / index.jsp telnet://localhost:8000/ 9/13/2018 V.B.Sanghavi

URL constructors URL (String urlspecifier) URL ( String protocol, String host, int port, String path) Exception : MalformedURLException 9/13/2018 V.B.Sanghavi

Methods of URL class public String getProtocol() public String getHost() public String getPort() public String getFile() Public String toExternalForm() Program 9/13/2018 V.B.Sanghavi

URLConnection represents a communication link between the URL and the application. can be used to read and write data to the specified resource reffered by the URL. 9/13/2018 V.B.Sanghavi

Creating a URLConnection URL url = new URL ( some_url ); URLConnection connection = url.openConnection(); 9/13/2018 V.B.Sanghavi

public String getContentType() public long getExpiration() public long getDate() public String getContentType() public long getExpiration() public long getLastModified() public int getContentLength() public InputStream getInputStream() public OutputStream getOutputStream() 9/13/2018 V.B.Sanghavi

Program for URLConnection class to read the content of specified resource 9/13/2018 V.B.Sanghavi

Datagrams Bundles of information passed between machines. When released- no assurance regarding arrival. When received- no assurance regarding data reliability. 9/13/2018 V.B.Sanghavi

DatagramSocket class represents a connection-less socket for sending and receiving datagram packets Constructors DatagramSocket() //Sending DatagramSocket(int port) //receiving DatagramSocket(int port, InetAddress address) 9/13/2018 V.B.Sanghavi

DatagramPacket class The DatagramPacket is message that can be sent or received 9/13/2018 V.B.Sanghavi

Constructors DatagramPacket(byte[] data, int length) (While receiving the data) DatagramPacket(byte[] data, int length, InetAddress address, int port) (while sending the data) 9/13/2018 V.B.Sanghavi

Methods: InetAddress getAddress() Int getPort() byte[] getData() Int getLength() 9/13/2018 V.B.Sanghavi

Content Handler and Protocol Handler Handling a protocol taking care of the interaction between a client and a server generating requests in the correct format acknowledging that the data has been received 9/13/2018 V.B.Sanghavi

Handling the content converting the raw data into a format Java understands 9/13/2018 V.B.Sanghavi

ContentHandler implemented as subclasses of the ContentHandler getContent() associated with a specific MIME type through the use of the ContentHandlerFactory interface createContentHandler() 9/13/2018 V.B.Sanghavi

ProtocolHandler implemented as subclasses of the URLStreamHandler class openConnection() toExternalForm() to implement a custom protocol needed to access Web objects identified by URLs 9/13/2018 V.B.Sanghavi

createURLStreamHandler() associated with a specific protocol through the use of the URLStreamHandlerFactory createURLStreamHandler() 9/13/2018 V.B.Sanghavi