SlideShare a Scribd company logo
2
Most read
3
Most read
JAVA
Networking
Prepared by
Miss. Arati A. Gadgil
Java– Networking
The term network programming refers to writing programs
that execute across multiple devices (computers), in which the
devices are all connected to each other using a network
The java.net package provides support for the two common
network protocols:
•TCP: TCP stands for Transmission Control Protocol, which
allows for reliable communication between two applications.
TCP is typically used over the Internet Protocol, which is
referred to as TCP/IP.
•UDP: UDP stands for User Datagram Protocol, a connection-
less protocol that allows for packets of data to be transmitted
between applications. 2
Java Networking Terminology
IP Address: It is a logical address that can be changed
Protocol : TCP ,FTP ,Telnet ,SMTP ,POP etc.
Port Number : The port number is associated with the IP
address for communication between two applications.
MAC Address : MAC (Media Access Control) Address is a
unique identifier of NIC (Network Interface Controller).
Connection-oriented and connection-less protocol Socket:
In connection-oriented protocol, acknowledgement is sent by
the receiver. So it is reliable but slow. The example of
connection-oriented protocol is TCP.
But, in connection-less protocol, acknowledgement is not sent
by the receiver. So it is not reliable but fast. The example of
connection-less protocol is UDP
3
Java – URL
URL stands for Uniform Resource Locator and represents a
resource on the World Wide Web, such as a Web page or FTP
directory.
 
4
A URL contains many information:
Protocol
Server name or IP Address
Port Number
File Name or directory name
Port Number is an optional attribute.If port number is not
mentioned in the URL, it returns -1.
5
Java URLConnection class
The Java URLConnection class represents a communication
link between the URL and the application. This class can be
used to read and write data to the specified resource referred
by the URL.
public URLConnection openConnection()throws IOException
{ }
6
Socket class
A socket is simply an endpoint for communications
between the machines. The Socket class can be used to
create a socket.
1)public InputStream getInputStream()
returns the InputStream attached with this socket.
2) public OutputStream getOutputStream()
returns the OutputStream attached with this socket.
3) public synchronized void close()
closes this socket 7
8
ServerSocket class
The ServerSocket class can be used to create a server socket.
This object is used to establish communication with the
clients.
Methods
1) public Socket accept()
returns the socket and establish a connection between server
and client.
2) public synchronized void close()
closes the server socket.
Java DatagramSocket class
Java DatagramSocket class represents a connection-less socket
for sending and receiving datagram packets.
A datagram is basically an information but there is no
guarantee of its content, arrival or arrival time.
Constructors:
DatagramSocket() throws SocketEeption: it creates a
datagram socket and binds it with the available Port Number
on the localhost machine.
DatagramSocket(int port) throws SocketEeption: it creates
a datagram socket and binds it with the given Port Number.
DatagramSocket(int port, InetAddress address) throws
SocketEeption: it creates a datagram socket and binds it with
the specified port number and host address. 9
Java DatagramPacket class
Java DatagramPacket is a message that can be sent or
received. If you send multiple packet, it may arrive in any
order. Additionally, packet delivery is not guaranteed.
Constructors
DatagramPacket(byte[] barr, int length): it creates a
datagram packet. This constructor is used to receive the
packets.
DatagramPacket(byte[] barr, int length, InetAddress
address, int port): it creates a datagram packet. This
constructor is used to send the packets. 10
Thank You
11

More Related Content

PPT
Java Network Programming
PDF
Java Programming - 07 java networking
PPTX
Advance Java-Network Programming
PPT
Java Networking
PPT
Java Networking
PPT
Networking in java
PDF
Java networking programs - theory
PPT
Network programming in Java
Java Network Programming
Java Programming - 07 java networking
Advance Java-Network Programming
Java Networking
Java Networking
Networking in java
Java networking programs - theory
Network programming in Java

What's hot (20)

PPTX
Networking in Java
PPT
Java API: java.net.InetAddress
PDF
Java networking programs socket based
PPT
java networking
PPT
Network programming in Java
PDF
Chap 1 Network Theory & Java Overview
PPT
Socket Programming - nitish nagar
PPTX
Java networking
PDF
28 networking
PPTX
PPT
Network Programming in Java
PPT
Basic Networking in Java
PDF
Networking in java, Advanced programming
PPT
Socket Programming
PPT
Md13 networking
PDF
Module 1 networking basics-2
PPTX
Socket programming or network programming
PPTX
Python Sockets
DOCX
Simple chat room using python
PPTX
Java - Sockets
Networking in Java
Java API: java.net.InetAddress
Java networking programs socket based
java networking
Network programming in Java
Chap 1 Network Theory & Java Overview
Socket Programming - nitish nagar
Java networking
28 networking
Network Programming in Java
Basic Networking in Java
Networking in java, Advanced programming
Socket Programming
Md13 networking
Module 1 networking basics-2
Socket programming or network programming
Python Sockets
Simple chat room using python
Java - Sockets
Ad

Viewers also liked (10)

PPT
Networking Java Socket Programming
PDF
Socket programming using java
PPTX
Network programming in java - PPT
PPT
Sockets
PPTX
Stop guessing - make cashless payments a success
PPSX
Network protocols and Java programming
PPTX
Geometric transformation 2d chapter 5
PPT
Socket Programming Tutorial
PPT
2 d transformations by amit kumar (maimt)
PPT
Lan chat system
Networking Java Socket Programming
Socket programming using java
Network programming in java - PPT
Sockets
Stop guessing - make cashless payments a success
Network protocols and Java programming
Geometric transformation 2d chapter 5
Socket Programming Tutorial
2 d transformations by amit kumar (maimt)
Lan chat system
Ad

Similar to Java networking (20)

PPTX
Java seminar.pptx
PPTX
Chapter 4
PPTX
PPTX
Client server chat application
PPT
Java Network Programming 1197644949195966 4
PPTX
Java Network Programming.pptx
PDF
PPT
Unit 8 Java
PDF
Socket programming
PPT
Unit 2 DSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDS.ppt
DOCX
Mail Server Project Report
PPTX
Tcp/ip server sockets
PPT
Networking
PDF
Socket Programming by Rajkumar Buyya
PPTX
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
PPTX
Chuong5_Networking_updated.Networking_updatedpptx
PDF
Networking
PPTX
OOP Lecture 24-Network Programming-Part1.pptx
PPTX
Distributed Systems inter process communication
PDF
NP-lab-manual.pdf
Java seminar.pptx
Chapter 4
Client server chat application
Java Network Programming 1197644949195966 4
Java Network Programming.pptx
Unit 8 Java
Socket programming
Unit 2 DSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDS.ppt
Mail Server Project Report
Tcp/ip server sockets
Networking
Socket Programming by Rajkumar Buyya
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
Chuong5_Networking_updated.Networking_updatedpptx
Networking
OOP Lecture 24-Network Programming-Part1.pptx
Distributed Systems inter process communication
NP-lab-manual.pdf

More from Arati Gadgil (16)

PPT
Java adapter
PPT
Java swing
PPT
Java applet
PPT
Java layoutmanager
PPT
Java awt
PPT
Java stream
PPT
Java thread
PPT
Java jdbc
PPT
Java package
PPT
Java interface
PPT
Java inheritance
PPT
Java eventhandling
PPT
Java exception
PPT
Java collection
PPT
Java class
PPT
Java basic
Java adapter
Java swing
Java applet
Java layoutmanager
Java awt
Java stream
Java thread
Java jdbc
Java package
Java interface
Java inheritance
Java eventhandling
Java exception
Java collection
Java class
Java basic

Recently uploaded (20)

PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Institutional Correction lecture only . . .
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Complications of Minimal Access Surgery at WLH
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
TR - Agricultural Crops Production NC III.pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Pharma ospi slides which help in ospi learning
Abdominal Access Techniques with Prof. Dr. R K Mishra
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Institutional Correction lecture only . . .
01-Introduction-to-Information-Management.pdf
Cell Structure & Organelles in detailed.
Microbial disease of the cardiovascular and lymphatic systems
Anesthesia in Laparoscopic Surgery in India
Final Presentation General Medicine 03-08-2024.pptx
Renaissance Architecture: A Journey from Faith to Humanism
Complications of Minimal Access Surgery at WLH
STATICS OF THE RIGID BODIES Hibbelers.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx

Java networking

  • 2. Java– Networking The term network programming refers to writing programs that execute across multiple devices (computers), in which the devices are all connected to each other using a network The java.net package provides support for the two common network protocols: •TCP: TCP stands for Transmission Control Protocol, which allows for reliable communication between two applications. TCP is typically used over the Internet Protocol, which is referred to as TCP/IP. •UDP: UDP stands for User Datagram Protocol, a connection- less protocol that allows for packets of data to be transmitted between applications. 2
  • 3. Java Networking Terminology IP Address: It is a logical address that can be changed Protocol : TCP ,FTP ,Telnet ,SMTP ,POP etc. Port Number : The port number is associated with the IP address for communication between two applications. MAC Address : MAC (Media Access Control) Address is a unique identifier of NIC (Network Interface Controller). Connection-oriented and connection-less protocol Socket: In connection-oriented protocol, acknowledgement is sent by the receiver. So it is reliable but slow. The example of connection-oriented protocol is TCP. But, in connection-less protocol, acknowledgement is not sent by the receiver. So it is not reliable but fast. The example of connection-less protocol is UDP 3
  • 4. Java – URL URL stands for Uniform Resource Locator and represents a resource on the World Wide Web, such as a Web page or FTP directory.   4
  • 5. A URL contains many information: Protocol Server name or IP Address Port Number File Name or directory name Port Number is an optional attribute.If port number is not mentioned in the URL, it returns -1. 5
  • 6. Java URLConnection class The Java URLConnection class represents a communication link between the URL and the application. This class can be used to read and write data to the specified resource referred by the URL. public URLConnection openConnection()throws IOException { } 6
  • 7. Socket class A socket is simply an endpoint for communications between the machines. The Socket class can be used to create a socket. 1)public InputStream getInputStream() returns the InputStream attached with this socket. 2) public OutputStream getOutputStream() returns the OutputStream attached with this socket. 3) public synchronized void close() closes this socket 7
  • 8. 8 ServerSocket class The ServerSocket class can be used to create a server socket. This object is used to establish communication with the clients. Methods 1) public Socket accept() returns the socket and establish a connection between server and client. 2) public synchronized void close() closes the server socket.
  • 9. Java DatagramSocket class Java DatagramSocket class represents a connection-less socket for sending and receiving datagram packets. A datagram is basically an information but there is no guarantee of its content, arrival or arrival time. Constructors: DatagramSocket() throws SocketEeption: it creates a datagram socket and binds it with the available Port Number on the localhost machine. DatagramSocket(int port) throws SocketEeption: it creates a datagram socket and binds it with the given Port Number. DatagramSocket(int port, InetAddress address) throws SocketEeption: it creates a datagram socket and binds it with the specified port number and host address. 9
  • 10. Java DatagramPacket class Java DatagramPacket is a message that can be sent or received. If you send multiple packet, it may arrive in any order. Additionally, packet delivery is not guaranteed. Constructors DatagramPacket(byte[] barr, int length): it creates a datagram packet. This constructor is used to receive the packets. DatagramPacket(byte[] barr, int length, InetAddress address, int port): it creates a datagram packet. This constructor is used to send the packets. 10