Networking.

Slides:



Advertisements
Similar presentations
Sockets for Clients Socket Basics  Connect to a remote machine  Send data  Receive data  Close a connection  Bind to a port 
Advertisements

Programming TCP Clients Version InetAddress Class An IP address identifies uniquely a host in the internet, which consists of 4 numbers (1 byte.
Prepared By E. Musa Alyaman1 Java Network Programming TCP.
Prepared By E. Musa Alyaman1 URLs, InetAddresses, and URLConnections Chapter 9.
Java Sockets Source:
Basic Socket Programming with Java. What is a socket?  Generally refers to a stream connecting processes running in different address spaces (across.
WECPP1 Java networking Jim Briggs based on notes by Amanda Peart based on Bell & Parr's bonus chapter
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
Programming TCP Clients. InetAddress Class An IP address identifies uniquely a host in the internet, which consists of 4 numbers (1 byte each one) in.
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.
Lecture 11 Java Socket Programming CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger and Joonbok Lee.
Client/Server In Java An Introduction to TCP/IP and Sockets.
Programming TCP Clients. InetAddress Class An IP address identifies uniquely a host in the internet, which consists of 4 numbers (1 byte each one) in.
Networking Support In Java Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Programming TCP Clients Version InetAddress Class An IP address identifies uniquely a host in the internet, which consists of 4 numbers (1 byte.
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.
Networking in Java Representation and Management of Data on the Internet.
Java Networking.
Socket Programming -What is it ? -Why bother ?. Basic Interface for programming networks at transport level It is communication end point Used for inter.
JAVA - Network DUT Info - Option ISI (C) Philippe Roose , 2005.
Multicast Sockets What is a multicast socket?
Appendix F: Network Programming in Java ©SoftMoore ConsultingSlide 1.
Application Protocols: HTTP CSNB534 Semester 2, 2007/2008 Asma Shakil.
Introduction/Warmup Java Socket Programming.  Stream connecting processes running in different address spaces  Can be across a network or on the same.
Import java.net.*; import java.io.*; public class LowPortScanner { public static void main(String[] args) { String host = "localhost"; if (args.length.
DBI Representation and Management of Data on the Internet.
1 A TCP/IP Application Programming Perspective Chris Greenhalgh G53ACC.
Object Oriented Programming in Java Lecture 16. Networking in Java Concepts Technicalities in java.
Java Sockets Programming
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
Networks Sockets and Streams. TCP/IP in action server ports …65535 lower port numbers ( ) are reserved port echo7 time13 ftp20 telnet23.
Sockets For Clients Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Java Networking. java.net package provides support of networking. Its creators have called Java "programming for the Internet." What makes Java a good.
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 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.
URL Programming Mimi Opkins CECS277. What is a URL?  URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on.
Distributed Systems CS Project 1: File Storage and Access Kit (FileStack) Recitation 1, Aug 29, 2013 Dania Abed Rabbou and Mohammad Hammoud.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
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.
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
Network Programming. These days almost all devices.
Network Programming Communication between processes Many approaches:
Java 13. Networking public class SumTest {
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:
Chapter 03 Networking & Security
Topic: Network programming
Network Programming Introduction
NETWORK PROGRAMMING CNET 441
An Introduction to TCP/IP and Sockets
PRESENTED To: Sir Abid………. PRESENTED BY: Insharah khan………. SUBJECT:
Network Programming Introduction
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).
Sockets and URLs 3-Dec-18.
Java Socket Programming
Programming TCP Sockets
Uniform Resource Locator: URL
Programming TCP Clients
Presentation transcript:

Networking

Class InetAddress This class represents an Internet Protocol (IP) address . getAddress public byte[] getAddress() Returns the raw IP address of this InetAddress object. The result is in network byte order: the highest order byte of the address is in getAddress()[0]. getHostAddress public String getHostAddress() Returns the IP address string

getByName(String host) throws UnknownHostException Determines the IP address of a host, given the host's name. The host name can either be a machine name, such as "java.sun.com", or a string representing its IP address, such as "206.26.48.100". Parameters: host - the specified host, or null for the local host. Returns: an IP address for the given host name. Throws: UnknownHostException - if no IP address for the host could be found.

InetAddress[] getAllByName(String host) Determines all the IP addresses of a host, given the host's name. getLocalHost Returns the local host. getHostName Gets the host name for this IP address. public boolean isMulticastAddress() Utility routine to check if the InetAddress is an IP multicast address. Logical identifier for a group of hosts.

java.net.URL The java.net.URL class represents a URL. There are constructors to create new URLs and methods to parse the different parts of a URL public URL(String u) throws MalformedURLException public URL(String protocol, String host, String file) throws MalformedURLException public URL(String protocol, String host, int port, String file) throws MalformedURLException

URL like http://www.xyz.edu/schedule/summer2011/bgrad.html#cs URL u = new URL(" http://www.xyz.edu/schedule/summer2011/bgrad.html#cs "); u = new URL("http", "www.xyz.edu", "/schedule/summer2011/bgrad.html#cs"); u = new URL("http", "www.xyz.edu", 80, "/schedule/summer2011/bgrad.html#cs");

Methods public String getProtocol() public String getHost() Gets the protocol name of this URL. public String getHost() Gets the host name of this URL, public String getFile() Gets the file name of this URL

public String getPath() public String toExternalForm()  Gets the path part of this URL. public String toExternalForm()  returns a human-readable String representing the URL . Public String sameFile(Url u) Compares two URLs public int getPort() Gets the port number of this URL

If a port is not explicitly specified in the URL, it's set to -1. This does not mean that the connection is attempted on port -1 (which doesn't exist) but rather that the default port is to be used.

Socket Class This class handles client sockets . The java.net.Socket class allows you to connect to remote machines send data; receive data; close the connection. public Socket(String host, int port) throws UnknownHostException, IOException public Socket(InetAddress address, int port) throws IOException

 int getPort()           Returns the remote port to which this socket is connected. Int getLocalPort()           Returns the local port to which this socket is bound.  InetAddress getInetAddress()           Returns the address to which the socket is connected.  InputStream getInputStream()           Returns an input stream for this socket. OutputStream getOutputStream()           Returns an output stream for this socket.

Once a socket has connected you send data to the server via an output stream. You receive data from the server via an input stream.