SlideShare a Scribd company logo
2
Most read
7
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
backdoor
 
PDF
Java Programming - 07 java networking
Danairat Thanabodithammachari
 
PPTX
Advance Java-Network Programming
ashok hirpara
 
PPT
Java Networking
Sunil OS
 
PPT
Java Networking
Ankit Desai
 
PPT
Networking in java
shravan kumar upadhayay
 
PDF
Java networking programs - theory
Mukesh Tekwani
 
PPT
Network programming in Java
Tushar B Kute
 
Java Network Programming
backdoor
 
Java Programming - 07 java networking
Danairat Thanabodithammachari
 
Advance Java-Network Programming
ashok hirpara
 
Java Networking
Sunil OS
 
Java Networking
Ankit Desai
 
Networking in java
shravan kumar upadhayay
 
Java networking programs - theory
Mukesh Tekwani
 
Network programming in Java
Tushar B Kute
 

What's hot (20)

PPTX
Networking in Java
Tushar B Kute
 
PPT
Java API: java.net.InetAddress
Sayak Sarkar
 
PDF
Java networking programs socket based
Mukesh Tekwani
 
PPT
java networking
Waheed Warraich
 
PPT
Network programming in Java
Tushar B Kute
 
PDF
Chap 1 Network Theory & Java Overview
Ministry of Higher Education
 
PPT
Socket Programming - nitish nagar
Nitish Nagar
 
PPTX
Java networking
ssuser3a47cb
 
PDF
28 networking
Ravindra Rathore
 
PPTX
Java 1
VidyaVarshini3
 
PPT
Network Programming in Java
Tushar B Kute
 
PPT
Basic Networking in Java
suraj pandey
 
PDF
Networking in java, Advanced programming
Gera Paulos
 
PPT
Socket Programming
CEC Landran
 
PPT
Md13 networking
Rakesh Madugula
 
PDF
Module 1 networking basics-2
Ankit Dubey
 
PPTX
Socket programming or network programming
Mmanan91
 
PPTX
Python Sockets
pythontic
 
DOCX
Simple chat room using python
VISHAL VERMA
 
PPTX
Java - Sockets
Riccardo Cardin
 
Networking in Java
Tushar B Kute
 
Java API: java.net.InetAddress
Sayak Sarkar
 
Java networking programs socket based
Mukesh Tekwani
 
java networking
Waheed Warraich
 
Network programming in Java
Tushar B Kute
 
Chap 1 Network Theory & Java Overview
Ministry of Higher Education
 
Socket Programming - nitish nagar
Nitish Nagar
 
Java networking
ssuser3a47cb
 
28 networking
Ravindra Rathore
 
Network Programming in Java
Tushar B Kute
 
Basic Networking in Java
suraj pandey
 
Networking in java, Advanced programming
Gera Paulos
 
Socket Programming
CEC Landran
 
Md13 networking
Rakesh Madugula
 
Module 1 networking basics-2
Ankit Dubey
 
Socket programming or network programming
Mmanan91
 
Python Sockets
pythontic
 
Simple chat room using python
VISHAL VERMA
 
Java - Sockets
Riccardo Cardin
 
Ad

Viewers also liked (10)

PPT
Networking Java Socket Programming
Mousmi Pawar
 
PDF
Socket programming using java
UC San Diego
 
PPTX
Network programming in java - PPT
kamal kotecha
 
PPT
Sockets
sivindia
 
PPTX
Stop guessing - make cashless payments a success
BSGAfrica
 
PPSX
Network protocols and Java programming
difatta
 
PPTX
Geometric transformation 2d chapter 5
geethawilliam
 
PPT
Socket Programming Tutorial
Jignesh Patel
 
PPT
2 d transformations by amit kumar (maimt)
Amit Kapoor
 
PPT
Lan chat system
Wipro
 
Networking Java Socket Programming
Mousmi Pawar
 
Socket programming using java
UC San Diego
 
Network programming in java - PPT
kamal kotecha
 
Sockets
sivindia
 
Stop guessing - make cashless payments a success
BSGAfrica
 
Network protocols and Java programming
difatta
 
Geometric transformation 2d chapter 5
geethawilliam
 
Socket Programming Tutorial
Jignesh Patel
 
2 d transformations by amit kumar (maimt)
Amit Kapoor
 
Lan chat system
Wipro
 
Ad

Similar to Java networking (20)

PPTX
Java seminar.pptx
shirindigitel
 
PPTX
Chapter 4
Ebisa Bekele
 
PPTX
Java
Subha Selvam
 
PPTX
Client server chat application
Samsil Arefin
 
PPT
Java Network Programming 1197644949195966 4
chendi.bhargavi
 
PPTX
Java Network Programming.pptx
RoshniSundrani
 
PDF
Lecture25
Debasish Pratihari
 
PPT
Unit 8 Java
arnold 7490
 
PDF
Socket programming
Padmavathione
 
PPT
Unit 2 DSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDS.ppt
madhugvr4455
 
DOCX
Mail Server Project Report
Kavita Sharma
 
PPTX
Tcp/ip server sockets
rajshreemuthiah
 
PPT
Networking
nik.manjit
 
PDF
Socket Programming by Rajkumar Buyya
iDhawalVaja
 
PPTX
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
VijiPriya Jeyamani
 
PPTX
Chuong5_Networking_updated.Networking_updatedpptx
phuongnhu25720055
 
PDF
Networking
Tuan Ngo
 
PPTX
OOP Lecture 24-Network Programming-Part1.pptx
Tanzila Kehkashan
 
PPTX
Distributed Systems inter process communication
piyushingole7
 
PDF
NP-lab-manual.pdf
RaviRajput416403
 
Java seminar.pptx
shirindigitel
 
Chapter 4
Ebisa Bekele
 
Client server chat application
Samsil Arefin
 
Java Network Programming 1197644949195966 4
chendi.bhargavi
 
Java Network Programming.pptx
RoshniSundrani
 
Unit 8 Java
arnold 7490
 
Socket programming
Padmavathione
 
Unit 2 DSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDSDS.ppt
madhugvr4455
 
Mail Server Project Report
Kavita Sharma
 
Tcp/ip server sockets
rajshreemuthiah
 
Networking
nik.manjit
 
Socket Programming by Rajkumar Buyya
iDhawalVaja
 
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
VijiPriya Jeyamani
 
Chuong5_Networking_updated.Networking_updatedpptx
phuongnhu25720055
 
Networking
Tuan Ngo
 
OOP Lecture 24-Network Programming-Part1.pptx
Tanzila Kehkashan
 
Distributed Systems inter process communication
piyushingole7
 
NP-lab-manual.pdf
RaviRajput416403
 

More from Arati Gadgil (16)

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

Recently uploaded (20)

PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PPTX
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PDF
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PDF
Sunset Boulevard Student Revision Booklet
jpinnuck
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPT
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PDF
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
PPTX
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
Sunset Boulevard Student Revision Booklet
jpinnuck
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 

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