SlideShare a Scribd company logo
Unit-6-java basic for java programing.pptx
Networking Basic
0 Java networking supports the concept of Socket.
0 Socket
0 Identifies an endpoint in a n/w.
0 Allows a single computer to serve many different type of
information to many different client as well as server at
once.
0 This is accomplished through port(numbered socket on
a particular machine).
Networking Basic
0 Socket
0 Socket communication takes place via protocol
0IP
0 Low-level routing protocol
0 Breaks data into small packets and send them to an address across n/w
0 No guarantee to delivered.
0TCP
0 Higher level protocol
0 Manage packet robustly
0 Sort and retransmit them as necessary
0 Reliably transmit data
0UDP
0 Used directly to support fast ,connectionless , unreliable transport
packets.
InetAddress
0 Encapsulate both the numerical IP Address and the
domain name for the address.
0 Can handle IPv4 and IPv6
0 Factory Method
0 InetAddress class does not have visible constructor
0 To create an InetAddress object, you have to use one of
the available factory methods.
InetAddress
0 Factory Methods
0 static InetAddress getLocalHost( )throws
UnknownHostException
0 static InetAddress getByName(String hostName) throws
UnknownHostException
0 static InetAddress[ ] getAllByName(String hostName)
throws UnknownHostException
TCP/IP Sockets
0 Used to implement reliable, bidirectional, persistent,
point-to-point stream based connection between
hosts on the Internet.
0 There are two types of TCP sockets in Java; one is for
servers and other is for clients.
0 The ServerSocket class is for server and Socket is for
client.
0 The ServetSocket class is designed to be a “listener”,
which waits for clients to connect before do anything.
TCP/IP Sockets
0 The Socket class is designed to connect to server
sockets.
0 The creation of a Socket object implicitly established
connection between client and server.
0 Note: There are no methods or constructors that
explicitly expose the details of establishing that
connection.
TCP/IP Sockets
0 There are two constructor used to create client
socket:
0 Socket(String hostName, int port) throws
UnknownHostException, IOException
Creates a socket connected to the named host and
port.
0 Socket(InetAddress ipAddress, int port) throws
IOException
Creates a socket using a pre existing InetAddress
object and a port.
0 There are three constructor used to create server
socket:
0 ServerSocket(int port) throws IOException
0 Creates server socket on the specified port with a queue
length of 50.
0 ServerSocket(int port, int maxQueue) throws
IOException
0 Creates a server socket on the specified port with a
maximum queue length of maxQueue.
0 ServerSocket(int port, int maxQueue, InetAddress
localAddress) throws IOException
0 Creates a server socket on the specified port with a
maximum queue length of maxQueue. On a multihomed
host, localAddress specifies the IP address to which this
socket binds.
URL
0 Uniform Resource Locator
0 Provide reasonably intelligible form to uniquely
identify or address information on the Internet.
0 URLs are being every where at once every browser
uses them to identify information on the Web.
0 Within Java’s network class library, the URL class
provides a simple, concise (brief important
information) API to access information across the
Internet using URLs.
URL
0 A URL specification format is based on four
components.
0 Here are two examples: http://www.osborne.com/
and http://www.osborne.com:80/index.htm.
0 The first is the protocol to use, separated from the rest
of the locator by a colon (:).
0 Common protocols are HTTP, FTP, gopher.
0 The second component is the host name or IP address
of the host to use.
0 The third component, the port number, is an optional
parameter.
URL
0 The fourth part is the actual file path.
0Most HTTP servers will append a file named index.html or
index.htm to URLs that refer directly to a directory resource.
0 Constructor:
0 URL(String urlSpecifier) throws
MalformedURLException
0 URL(String protocolName, String hostName, int port,
String path) throws MalformedURLException
0 URL(String protocolName, String hostName, String path)
throws MalformedURLException
0 URL(URL urlObj, String urlSpecifier) throws
MalformedURLException
URLConnection
0 URLConnection is a general-purpose class for
accessing the attributes of a remote resource.
0 Once you make a connection to a remote server, you
can use URLConnection to inspect the properties of
the remote object before actually transporting it
locally
HttpURLConnection
0 Java provides a subclass of URLConnection that
provides support for HTTP connections.
0 We obtain an HttpURLConnection by calling
openConnection( ) on a URL object, but we must cast
the result to HttpURLConnection.
Datagrams
0 Datagram is basically an information but there is no
guarantee of packet delivery.
0 Java implements datagrams on top of the UDP
protocol by using two classes:
0 DatagramPacket
0 Is a message that can be sent or received.
0 If you send multiple packet, it may arrive in any order.
0 DatagramSocket
0 is the mechanism used to send or receive the
DatagramPackets.
DatagramSocket
0 Represents a connection-less socket for sending and
receiving datagram packet.
0 DatagramSocket defines four public constructors:
0 DatagramSocket( ) throws SocketException
0 DatagramSocket(int port) throws SocketException
0 DatagramSocket(int port, InetAddress ipAddress) throws
SocketException
0 DatagramSocket(SocketAddress address) throws
SocketException
DatagramSocket
0 Methods
0 void send(DatagramPacket packet) throws IOException
0 void receive(DatagramPacket packet) throws
IOException
DatagramPacket
0 Constructor:
0 DatagramPacket(byte data[ ], int size)
0 DatagramPacket(byte data[ ], int size, InetAddress
ipAddress, int port)

More Related Content

Similar to Unit-6-java basic for java programing.pptx (20)

PPT
Networking Java Socket Programming
Mousmi Pawar
 
PPTX
5_6278455688045789623.pptx
EliasPetros
 
PPT
Networking & Socket Programming In Java
Ankur Agrawal
 
PPT
Network programming in Java
Tushar B Kute
 
PDF
28 networking
Ravindra Rathore
 
PDF
Networking Basics1ofjavaprogramming.pptx.pdf
omkarthombare4989
 
PPT
Network Programming in Java
Tushar B Kute
 
PPTX
Java seminar.pptx
shirindigitel
 
DOC
T2
Mo Ch
 
PDF
javanetworking
Arjun Shanka
 
PPT
java networking
Waheed Warraich
 
PPTX
Network programming in java - PPT
kamal kotecha
 
PPT
Basic Networking in Java
suraj pandey
 
PPTX
Chapter 4
Ebisa Bekele
 
PPTX
Advance Java-Network Programming
ashok hirpara
 
PDF
chapter3 evemt handling and delighted model java mcq important mcq for 2023
bhagatsadesh96
 
PDF
Java networking programs - theory
Mukesh Tekwani
 
PPTX
CHAPTER - 3 - JAVA NETWORKING.pptx
DhrumilSheth3
 
PPTX
Socket & Server Socket
Hemant Chetwani
 
PPTX
Java socket programming
Mohammed Abdalla Youssif
 
Networking Java Socket Programming
Mousmi Pawar
 
5_6278455688045789623.pptx
EliasPetros
 
Networking & Socket Programming In Java
Ankur Agrawal
 
Network programming in Java
Tushar B Kute
 
28 networking
Ravindra Rathore
 
Networking Basics1ofjavaprogramming.pptx.pdf
omkarthombare4989
 
Network Programming in Java
Tushar B Kute
 
Java seminar.pptx
shirindigitel
 
T2
Mo Ch
 
javanetworking
Arjun Shanka
 
java networking
Waheed Warraich
 
Network programming in java - PPT
kamal kotecha
 
Basic Networking in Java
suraj pandey
 
Chapter 4
Ebisa Bekele
 
Advance Java-Network Programming
ashok hirpara
 
chapter3 evemt handling and delighted model java mcq important mcq for 2023
bhagatsadesh96
 
Java networking programs - theory
Mukesh Tekwani
 
CHAPTER - 3 - JAVA NETWORKING.pptx
DhrumilSheth3
 
Socket & Server Socket
Hemant Chetwani
 
Java socket programming
Mohammed Abdalla Youssif
 

Recently uploaded (20)

PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PPTX
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
Ad

Unit-6-java basic for java programing.pptx

  • 2. Networking Basic 0 Java networking supports the concept of Socket. 0 Socket 0 Identifies an endpoint in a n/w. 0 Allows a single computer to serve many different type of information to many different client as well as server at once. 0 This is accomplished through port(numbered socket on a particular machine).
  • 3. Networking Basic 0 Socket 0 Socket communication takes place via protocol 0IP 0 Low-level routing protocol 0 Breaks data into small packets and send them to an address across n/w 0 No guarantee to delivered. 0TCP 0 Higher level protocol 0 Manage packet robustly 0 Sort and retransmit them as necessary 0 Reliably transmit data 0UDP 0 Used directly to support fast ,connectionless , unreliable transport packets.
  • 4. InetAddress 0 Encapsulate both the numerical IP Address and the domain name for the address. 0 Can handle IPv4 and IPv6 0 Factory Method 0 InetAddress class does not have visible constructor 0 To create an InetAddress object, you have to use one of the available factory methods.
  • 5. InetAddress 0 Factory Methods 0 static InetAddress getLocalHost( )throws UnknownHostException 0 static InetAddress getByName(String hostName) throws UnknownHostException 0 static InetAddress[ ] getAllByName(String hostName) throws UnknownHostException
  • 6. TCP/IP Sockets 0 Used to implement reliable, bidirectional, persistent, point-to-point stream based connection between hosts on the Internet. 0 There are two types of TCP sockets in Java; one is for servers and other is for clients. 0 The ServerSocket class is for server and Socket is for client. 0 The ServetSocket class is designed to be a “listener”, which waits for clients to connect before do anything.
  • 7. TCP/IP Sockets 0 The Socket class is designed to connect to server sockets. 0 The creation of a Socket object implicitly established connection between client and server. 0 Note: There are no methods or constructors that explicitly expose the details of establishing that connection.
  • 8. TCP/IP Sockets 0 There are two constructor used to create client socket: 0 Socket(String hostName, int port) throws UnknownHostException, IOException Creates a socket connected to the named host and port. 0 Socket(InetAddress ipAddress, int port) throws IOException Creates a socket using a pre existing InetAddress object and a port.
  • 9. 0 There are three constructor used to create server socket: 0 ServerSocket(int port) throws IOException 0 Creates server socket on the specified port with a queue length of 50. 0 ServerSocket(int port, int maxQueue) throws IOException 0 Creates a server socket on the specified port with a maximum queue length of maxQueue. 0 ServerSocket(int port, int maxQueue, InetAddress localAddress) throws IOException 0 Creates a server socket on the specified port with a maximum queue length of maxQueue. On a multihomed host, localAddress specifies the IP address to which this socket binds.
  • 10. URL 0 Uniform Resource Locator 0 Provide reasonably intelligible form to uniquely identify or address information on the Internet. 0 URLs are being every where at once every browser uses them to identify information on the Web. 0 Within Java’s network class library, the URL class provides a simple, concise (brief important information) API to access information across the Internet using URLs.
  • 11. URL 0 A URL specification format is based on four components. 0 Here are two examples: http://www.osborne.com/ and http://www.osborne.com:80/index.htm. 0 The first is the protocol to use, separated from the rest of the locator by a colon (:). 0 Common protocols are HTTP, FTP, gopher. 0 The second component is the host name or IP address of the host to use. 0 The third component, the port number, is an optional parameter.
  • 12. URL 0 The fourth part is the actual file path. 0Most HTTP servers will append a file named index.html or index.htm to URLs that refer directly to a directory resource. 0 Constructor: 0 URL(String urlSpecifier) throws MalformedURLException 0 URL(String protocolName, String hostName, int port, String path) throws MalformedURLException 0 URL(String protocolName, String hostName, String path) throws MalformedURLException 0 URL(URL urlObj, String urlSpecifier) throws MalformedURLException
  • 13. URLConnection 0 URLConnection is a general-purpose class for accessing the attributes of a remote resource. 0 Once you make a connection to a remote server, you can use URLConnection to inspect the properties of the remote object before actually transporting it locally
  • 14. HttpURLConnection 0 Java provides a subclass of URLConnection that provides support for HTTP connections. 0 We obtain an HttpURLConnection by calling openConnection( ) on a URL object, but we must cast the result to HttpURLConnection.
  • 15. Datagrams 0 Datagram is basically an information but there is no guarantee of packet delivery. 0 Java implements datagrams on top of the UDP protocol by using two classes: 0 DatagramPacket 0 Is a message that can be sent or received. 0 If you send multiple packet, it may arrive in any order. 0 DatagramSocket 0 is the mechanism used to send or receive the DatagramPackets.
  • 16. DatagramSocket 0 Represents a connection-less socket for sending and receiving datagram packet. 0 DatagramSocket defines four public constructors: 0 DatagramSocket( ) throws SocketException 0 DatagramSocket(int port) throws SocketException 0 DatagramSocket(int port, InetAddress ipAddress) throws SocketException 0 DatagramSocket(SocketAddress address) throws SocketException
  • 17. DatagramSocket 0 Methods 0 void send(DatagramPacket packet) throws IOException 0 void receive(DatagramPacket packet) throws IOException
  • 18. DatagramPacket 0 Constructor: 0 DatagramPacket(byte data[ ], int size) 0 DatagramPacket(byte data[ ], int size, InetAddress ipAddress, int port)