SlideShare a Scribd company logo
By – Gaurav
GOFORELEARNING@GMAIL.COM
Go GrEEN !
SaveEnvironment!
There are 3 requirements to establish a network:
 Hardware: includes the computers, cables, modems,
hubs, etc
 Software: includes program to communicate between
server and clients
 Protocols: represent a way to establish connection
and helps in sending and receiving data in a standard
format.
By – Gaurav
GOFORELEARNING@GMAIL.COM
 TCP/IP is a standard protocol model used on any
network.
 TCP/IP model has got the following 5 layers:
1. Application layer
2. TCP
3. IP
4. Data link layer
5. Physical layer
By – Gaurav
GOFORELEARNING@GMAIL.COM
1. Application layer
◦ Application layer is the topmost layer.
◦ This layer receives data from the application and formats the
data.
◦ it sends that data to the next layer called TCP in the form of
continuous stream of bytes.
2. TCP
◦ Receives data from Application layer,
◦ TCP will divide it into small segments called ‘packets’. A
packet contains a group of bytes of data.
◦ These packets are then sent to next IP layer
By – Gaurav
GOFORELEARNING@GMAIL.COM
3. IP layer
◦ IP layer inserts the packets into envelopes called
‘frames’.
◦ Each frame contains a packet:
 IP address of destination computer,
 IP address of source computer,
 some additional bits useful in error detection and
correction.
◦ These frames are then sent to Data link layer
By – Gaurav
GOFORELEARNING@GMAIL.COM
4. Data Link Layer
◦ Receives frames from the IP Layer.
◦ Dispatches them to correct destination computer
on the network.
5. Physical Layer
◦ This layer is used to physically transmit data on
the network using the appropriate hardware.
By – Gaurav
GOFORELEARNING@GMAIL.COM
 TCP/IP takes care of number of bits sent and weather
all the bits are received duly by the destination
computer. so it is called ‘connection oriented reliable
protocol’.
 This protocol is highly suitable for transporting data
reliably on a network.
 Almost all the protocol on Internet uses TCP/IP
model internally.
By – Gaurav
GOFORELEARNING@GMAIL.COM
IP Address:
 An IP address is a Unique Identification number given
to every computer on the network.
 It contain four integer numbers in the range of 0 to
255 and separated by a dot as 209.191.88.254
DNS (domain naming service)
 DNS is the mapping of IP addresses to human
readable names.
FTP (file transfer protocol)
 Useful to download or upload files from and to the
server.
By – Gaurav
GOFORELEARNING@GMAIL.COM
HTTP(Hypertext transfer protocol)
 Most widely used protocol on Internet, which is used
to transfer web pages (.html) from one computer to
anoher computer on Internet.
SMTP (simple mail transfer protocol)
 Useful to send mails on network.
POP(post office protocol)
 Useful to receive mails into the mailboxes.
By – Gaurav
GOFORELEARNING@GMAIL.COM
 Protocol that transfer data in a connection less and
unreliable manner.
 It will not check how many bits are sent or received at
the other side during transmission of data.
 UDP is used to send images, audio files and video files.
 Sockets provide the communication mechanism
between two computers using TCP.
 A client program creates a socket on its end of the
communication and attempts to connect that socket to
a server.
 When the connection is made, the server creates a
socket object on its end of the communication.
By – Gaurav
GOFORELEARNING@GMAIL.COM
 The client in socket programming must know two
information:
◦ IP Address of Server, and
◦ Port number.
 We should use a new port number for each new
socket.
 A socket, at server side is called ‘server socket’ and
is created using ServerSocket class in Java.
 A socket, at client side is called ‘socket’ and is
created using Socket class in Java.
By – Gaurav
GOFORELEARNING@GMAIL.COM
 getByName() method of InetAddress class of java.net
package.
By – Gaurav
GOFORELEARNING@GMAIL.COM
getByName()
Host Name / Server
Name
InetAddress/
IP Address
 URL URL(Uniform Resource Locator) represents the
address that is specified to access some information or
resources on world wide web.
 http://www.goforelearning.com:80/index.html
 The URL contains 4 parts
◦ The protocol to use (http://).
◦ The server name or IP address of the server(www.goforelearning.com)
◦ The third part represents ports number, which is optional (:80)
◦ The last part is the file name or directory name that is referred
(index.html).
 URL is represented by a class ‘URL’ in java.net package.
URL obj = new URL(String protocol, String host, int port,
String path);
By – Gaurav
GOFORELEARNING@GMAIL.COM
URLConnection Class is useful to actually connect
to a website or resource on a network and get all
the details of the website.
For example,
 To know the details of www.yahoo.com
◦ We should pass the URL to the object of URL class.
◦ Then using openConnection() method, we should
establish a contact with the site on Internet.
◦ This method return URLConnection object.
◦ Then using URLConnection class method, we can
display all the details of the website and also content
of the webpage whose name is given in URL.
By – Gaurav
GOFORELEARNING@GMAIL.COM
By – Gaurav
GOFORELEARNING@GMAIL.COM
Server
Server
Socket
OutputStreamPrintStream
ServerSocket ss = new ServerSocket (8080);
Socket s = ss.accept();
OutputStream obj = s.getOutputStream();
PrintStream ps = new PrintStream (obj);
ps.println(str);
ss.close();
s.close()
ps.close
By – Gaurav
GOFORELEARNING@GMAIL.COM
Socket
BufferedReaderInputStream
Socket s = new Socket (“IPAddress” , port number) ;
InputStream obj = s.get InputStream();
BufferedReader br = new BufferedReader (new InputStreamReader(obj));
Str = br.readLine();
br.close();
s.close()
Client
In case you don’t have your computer in a network, you have to run
both the server and client programs in the same system. In that case,
you can use localhost in place of IPAddress. The work localhost
represents that the server is also locally available in the same system.
We need additional streams both at server and client.
 InputStream obj = s.getInputStream();
 BufferedReader br = new BufferedReader (new
InputStreamReader(obj));
 OutputStream obj = s. getOutputStream();
 DataOutputStream dos = new DataOutputStream(obj);
writeBytes() method of DataOutputStream can be used to
send strings in form of groups of bytes.
Thank You !
Go GrEEN !
Save Environment!
For Any Queries: GOFORELEARNING@GMAIL.COM

More Related Content

PPTX
Java Networking
PPT
Networking chapter III
PPT
Networking & Socket Programming In Java
PDF
Java networking programs socket based
PPT
connectivity utility
PPT
Java API: java.net.InetAddress
PPT
java networking
PPT
Network Programming in Java
Java Networking
Networking chapter III
Networking & Socket Programming In Java
Java networking programs socket based
connectivity utility
Java API: java.net.InetAddress
java networking
Network Programming in Java

What's hot (20)

PPT
Basic Networking in Java
DOCX
Simple chat room using python
PPTX
Python Sockets
PDF
Web tcp ip
PPTX
Java socket programming
PDF
Socket programming-in-python
PPT
retrieving the mail
TXT
2014 07-14 t14-50-08-netlog
PDF
Lec 6(Application Layer)
PDF
Ftp server configuration on cisco packet tracer
PPTX
Static NAT
PPT
Socket programming-tutorial-sk
PPTX
Network programming in java - PPT
PPT
Under the Covers with the Web
PPT
A Short Java Socket Tutorial
PDF
Wireshark Lab HTTP, DNS and ARP v7 solution
PPTX
DHCP & DNS
PPTX
Basics about IP address, DNS and DHCP.
PDF
Wireshark lab ssl v7 solution
Basic Networking in Java
Simple chat room using python
Python Sockets
Web tcp ip
Java socket programming
Socket programming-in-python
retrieving the mail
2014 07-14 t14-50-08-netlog
Lec 6(Application Layer)
Ftp server configuration on cisco packet tracer
Static NAT
Socket programming-tutorial-sk
Network programming in java - PPT
Under the Covers with the Web
A Short Java Socket Tutorial
Wireshark Lab HTTP, DNS and ARP v7 solution
DHCP & DNS
Basics about IP address, DNS and DHCP.
Wireshark lab ssl v7 solution
Ad

Similar to Networking in Java (20)

PPTX
PPT
Networking Java Socket Programming
PPTX
5_6278455688045789623.pptx
PDF
Networking Basics1ofjavaprogramming.pptx.pdf
PPTX
Advanced Java Programming: Introduction and Overview of Java Networking 1. In...
PPTX
Networking.pptx
PPT
chapter-4-networking hjgjjgj did hfhhfhj
PDF
28 networking
PPTX
Java seminar.pptx
PPTX
Chuong5_Networking_updated.Networking_updatedpptx
DOCX
Mail Server Project Report
PPT
PPT
The Internet protocol suite, commonly known as TCP/IP, is a framework for org...
PPTX
PPTX
Networking in Java
PDF
Networking
PPTX
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
PPTX
network protocol | Networking by Nitasha Chaturvedi
PPT
Network programming in Java
PPTX
uniti-websitebasics-230517110223-12e31dbc (1).pptx
Networking Java Socket Programming
5_6278455688045789623.pptx
Networking Basics1ofjavaprogramming.pptx.pdf
Advanced Java Programming: Introduction and Overview of Java Networking 1. In...
Networking.pptx
chapter-4-networking hjgjjgj did hfhhfhj
28 networking
Java seminar.pptx
Chuong5_Networking_updated.Networking_updatedpptx
Mail Server Project Report
The Internet protocol suite, commonly known as TCP/IP, is a framework for org...
Networking in Java
Networking
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
network protocol | Networking by Nitasha Chaturvedi
Network programming in Java
uniti-websitebasics-230517110223-12e31dbc (1).pptx
Ad

Recently uploaded (20)

PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
Lesson notes of climatology university.
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Complications of Minimal Access Surgery at WLH
PDF
Insiders guide to clinical Medicine.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Sports Quiz easy sports quiz sports quiz
PDF
RMMM.pdf make it easy to upload and study
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Computing-Curriculum for Schools in Ghana
Microbial disease of the cardiovascular and lymphatic systems
Anesthesia in Laparoscopic Surgery in India
Renaissance Architecture: A Journey from Faith to Humanism
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Institutional Correction lecture only . . .
Lesson notes of climatology university.
Abdominal Access Techniques with Prof. Dr. R K Mishra
Complications of Minimal Access Surgery at WLH
Insiders guide to clinical Medicine.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Sports Quiz easy sports quiz sports quiz
RMMM.pdf make it easy to upload and study
2.FourierTransform-ShortQuestionswithAnswers.pdf
Computing-Curriculum for Schools in Ghana

Networking in Java

  • 1. By – Gaurav GOFORELEARNING@GMAIL.COM Go GrEEN ! SaveEnvironment!
  • 2. There are 3 requirements to establish a network:  Hardware: includes the computers, cables, modems, hubs, etc  Software: includes program to communicate between server and clients  Protocols: represent a way to establish connection and helps in sending and receiving data in a standard format. By – Gaurav GOFORELEARNING@GMAIL.COM
  • 3.  TCP/IP is a standard protocol model used on any network.  TCP/IP model has got the following 5 layers: 1. Application layer 2. TCP 3. IP 4. Data link layer 5. Physical layer By – Gaurav GOFORELEARNING@GMAIL.COM
  • 4. 1. Application layer ◦ Application layer is the topmost layer. ◦ This layer receives data from the application and formats the data. ◦ it sends that data to the next layer called TCP in the form of continuous stream of bytes. 2. TCP ◦ Receives data from Application layer, ◦ TCP will divide it into small segments called ‘packets’. A packet contains a group of bytes of data. ◦ These packets are then sent to next IP layer By – Gaurav GOFORELEARNING@GMAIL.COM
  • 5. 3. IP layer ◦ IP layer inserts the packets into envelopes called ‘frames’. ◦ Each frame contains a packet:  IP address of destination computer,  IP address of source computer,  some additional bits useful in error detection and correction. ◦ These frames are then sent to Data link layer By – Gaurav GOFORELEARNING@GMAIL.COM
  • 6. 4. Data Link Layer ◦ Receives frames from the IP Layer. ◦ Dispatches them to correct destination computer on the network. 5. Physical Layer ◦ This layer is used to physically transmit data on the network using the appropriate hardware. By – Gaurav GOFORELEARNING@GMAIL.COM
  • 7.  TCP/IP takes care of number of bits sent and weather all the bits are received duly by the destination computer. so it is called ‘connection oriented reliable protocol’.  This protocol is highly suitable for transporting data reliably on a network.  Almost all the protocol on Internet uses TCP/IP model internally. By – Gaurav GOFORELEARNING@GMAIL.COM
  • 8. IP Address:  An IP address is a Unique Identification number given to every computer on the network.  It contain four integer numbers in the range of 0 to 255 and separated by a dot as 209.191.88.254 DNS (domain naming service)  DNS is the mapping of IP addresses to human readable names. FTP (file transfer protocol)  Useful to download or upload files from and to the server. By – Gaurav GOFORELEARNING@GMAIL.COM
  • 9. HTTP(Hypertext transfer protocol)  Most widely used protocol on Internet, which is used to transfer web pages (.html) from one computer to anoher computer on Internet. SMTP (simple mail transfer protocol)  Useful to send mails on network. POP(post office protocol)  Useful to receive mails into the mailboxes. By – Gaurav GOFORELEARNING@GMAIL.COM
  • 10.  Protocol that transfer data in a connection less and unreliable manner.  It will not check how many bits are sent or received at the other side during transmission of data.  UDP is used to send images, audio files and video files.
  • 11.  Sockets provide the communication mechanism between two computers using TCP.  A client program creates a socket on its end of the communication and attempts to connect that socket to a server.  When the connection is made, the server creates a socket object on its end of the communication. By – Gaurav GOFORELEARNING@GMAIL.COM
  • 12.  The client in socket programming must know two information: ◦ IP Address of Server, and ◦ Port number.  We should use a new port number for each new socket.  A socket, at server side is called ‘server socket’ and is created using ServerSocket class in Java.  A socket, at client side is called ‘socket’ and is created using Socket class in Java. By – Gaurav GOFORELEARNING@GMAIL.COM
  • 13.  getByName() method of InetAddress class of java.net package. By – Gaurav GOFORELEARNING@GMAIL.COM getByName() Host Name / Server Name InetAddress/ IP Address
  • 14.  URL URL(Uniform Resource Locator) represents the address that is specified to access some information or resources on world wide web.  http://www.goforelearning.com:80/index.html  The URL contains 4 parts ◦ The protocol to use (http://). ◦ The server name or IP address of the server(www.goforelearning.com) ◦ The third part represents ports number, which is optional (:80) ◦ The last part is the file name or directory name that is referred (index.html).  URL is represented by a class ‘URL’ in java.net package. URL obj = new URL(String protocol, String host, int port, String path); By – Gaurav GOFORELEARNING@GMAIL.COM
  • 15. URLConnection Class is useful to actually connect to a website or resource on a network and get all the details of the website. For example,  To know the details of www.yahoo.com ◦ We should pass the URL to the object of URL class. ◦ Then using openConnection() method, we should establish a contact with the site on Internet. ◦ This method return URLConnection object. ◦ Then using URLConnection class method, we can display all the details of the website and also content of the webpage whose name is given in URL. By – Gaurav GOFORELEARNING@GMAIL.COM
  • 16. By – Gaurav GOFORELEARNING@GMAIL.COM Server Server Socket OutputStreamPrintStream ServerSocket ss = new ServerSocket (8080); Socket s = ss.accept(); OutputStream obj = s.getOutputStream(); PrintStream ps = new PrintStream (obj); ps.println(str); ss.close(); s.close() ps.close
  • 17. By – Gaurav GOFORELEARNING@GMAIL.COM Socket BufferedReaderInputStream Socket s = new Socket (“IPAddress” , port number) ; InputStream obj = s.get InputStream(); BufferedReader br = new BufferedReader (new InputStreamReader(obj)); Str = br.readLine(); br.close(); s.close() Client In case you don’t have your computer in a network, you have to run both the server and client programs in the same system. In that case, you can use localhost in place of IPAddress. The work localhost represents that the server is also locally available in the same system.
  • 18. We need additional streams both at server and client.  InputStream obj = s.getInputStream();  BufferedReader br = new BufferedReader (new InputStreamReader(obj));  OutputStream obj = s. getOutputStream();  DataOutputStream dos = new DataOutputStream(obj); writeBytes() method of DataOutputStream can be used to send strings in form of groups of bytes.
  • 19. Thank You ! Go GrEEN ! Save Environment! For Any Queries: GOFORELEARNING@GMAIL.COM