SlideShare a Scribd company logo
1 of 63
Java Network Programming Tushar B. Kute Assistant Professor Department of Information Technology, Sandip Institute of Technology and Research Centre, Nashik.
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
“ The Network is Computer” Internet Server PC client Local Area Network PDA
Increased demand for Internet applications ,[object Object],[object Object],[object Object]
Elements of C-S Computing Network Request Result a client, a server, and network Client Server Client machine Server machine
Networking Basics  ,[object Object]
DNS - Domain name system  ,[object Object],[object Object],[object Object]
Understanding Ports ,[object Object],server P o r t Client TCP TCP or UDP port port port port app app app app port# data Data Packet
Understanding Ports ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sockets ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Socket Communication ,[object Object],server Client Connection request port
Socket Communication ,[object Object],server Client Connection port port port
Transmission Control Protocol ,[object Object],[object Object],[object Object],[object Object]
User Datagram Protocol ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ports ,[object Object],[object Object]
Ports – Cont. ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Networking Classes in the JDK ,[object Object],[object Object],[object Object]
TCP/IP in Java ,[object Object],[object Object],[object Object],[object Object]
InetAddress ,[object Object],[object Object],[object Object]
Factory Methods ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example: ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Instance Methods ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sockets and Java Socket Classes ,[object Object],[object Object],[object Object],[object Object],[object Object]
Java Sockets ServerSocket(1234) Socket(“128.250.25.158”, 1234) Output/write stream Input/read stream It can be host_name like “books.google.com” Client Server
Client Sockets ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Constructors ,[object Object],[object Object]
Instance   Methods ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Implementing a Client ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Whois server ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Time server ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ServerSocket ,[object Object],[object Object]
Constructors ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Implementing a Server ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Accepting Connections ,[object Object],[object Object],[object Object],[object Object],[object Object]
Client-Server Interaction via TCP
Examples ,[object Object],[object Object]
URL -  Uniform Resource Locator   ,[object Object],[object Object],[object Object],[object Object],Protocol Host Name Port Number Path & File Name Reference
Class  URL ,[object Object],[object Object],[object Object],[object Object]
Constructors ,[object Object],[object Object],[object Object],[object Object]
Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Output ,[object Object],[object Object],[object Object],[object Object],[object Object]
URLConnection ,[object Object],[object Object],[object Object]
Process ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Reading Data from Server ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],URLConnection Example
Difference between URL and URLConnection ,[object Object],[object Object],[object Object]
Header Information ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Methods ,[object Object],[object Object],[object Object],[object Object],[object Object]
Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],catch (MalformedURLException ex)  { System.out.println("I can't understand this URL.."); } catch (IOException ex)  { System.err.println(ex); }  System.out.println( );  }  // end main }  // end HeaderViewer
Sample Output ,[object Object],[object Object],[object Object],[object Object]
Retrieving Header field ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Datagrams ,[object Object],[object Object]
TCP vs. UDP No. TCP UDP 1 This Connection oriented protocol  This is connection-less protocol 2 The TCP connection is byte stream The UDP connection is a message stream 3 It does not support multicasting and broadcasting It supports broadcasting 4 It provides error control and flow control The error control and flow control is not provided 5 TCP supports full duplex transmission UDP does not support full duplex transmission 6 It is reliable service of data transmission This is an unreliable service of data transmission  7 The TCP packet is called as segment The UDP packet is called as user datagram.
UDP in Java ,[object Object],[object Object]
Receiving DatagramPacket ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sending Datagrams ,[object Object],[object Object]
DatagramSocket ,[object Object],[object Object],[object Object]
Sending and Receiving Packets  ,[object Object],[object Object]
Example : ,[object Object],[object Object]
References ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
References ,[object Object],[object Object],[object Object],[object Object],[object Object]
Thank You [email_address]

More Related Content

What's hot

Socket programming in Java (PPTX)
Socket programming in Java (PPTX)Socket programming in Java (PPTX)
Socket programming in Java (PPTX)
UC San Diego
 
Network intrusion detection system and analysis
Network intrusion detection system and analysisNetwork intrusion detection system and analysis
Network intrusion detection system and analysis
Bikrant Gautam
 

What's hot (20)

Socket programming in Java (PPTX)
Socket programming in Java (PPTX)Socket programming in Java (PPTX)
Socket programming in Java (PPTX)
 
The constrained application protocol (CoAP)
The constrained application protocol (CoAP)The constrained application protocol (CoAP)
The constrained application protocol (CoAP)
 
Socket programming
Socket programming Socket programming
Socket programming
 
C I D R
C I D RC I D R
C I D R
 
OSI Network Layer
OSI Network LayerOSI Network Layer
OSI Network Layer
 
Switchdev - No More SDK
Switchdev - No More SDKSwitchdev - No More SDK
Switchdev - No More SDK
 
Network Sockets
Network SocketsNetwork Sockets
Network Sockets
 
Java socket programming
Java socket programmingJava socket programming
Java socket programming
 
Chapter 2 point-to-point protocol (ppp)
Chapter 2   point-to-point protocol (ppp)Chapter 2   point-to-point protocol (ppp)
Chapter 2 point-to-point protocol (ppp)
 
Computer security module 1
Computer security module 1Computer security module 1
Computer security module 1
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
 
Embedded linux network device driver development
Embedded linux network device driver developmentEmbedded linux network device driver development
Embedded linux network device driver development
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
 
Java Networking
Java NetworkingJava Networking
Java Networking
 
Network intrusion detection system and analysis
Network intrusion detection system and analysisNetwork intrusion detection system and analysis
Network intrusion detection system and analysis
 
SCADA and HMI Security in InduSoft Web Studio
SCADA and HMI Security in InduSoft Web StudioSCADA and HMI Security in InduSoft Web Studio
SCADA and HMI Security in InduSoft Web Studio
 
Linux Internals - Interview essentials - 1.0
Linux Internals - Interview essentials - 1.0Linux Internals - Interview essentials - 1.0
Linux Internals - Interview essentials - 1.0
 
Virtual machine and javascript engine
Virtual machine and javascript engineVirtual machine and javascript engine
Virtual machine and javascript engine
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using C
 

Viewers also liked (6)

JAVA Networking
JAVA NetworkingJAVA Networking
JAVA Networking
 
iPhone Apps
iPhone  AppsiPhone  Apps
iPhone Apps
 
Java networking
Java networkingJava networking
Java networking
 
Advance Java-Network Programming
Advance Java-Network ProgrammingAdvance Java-Network Programming
Advance Java-Network Programming
 
Digital wallet
Digital walletDigital wallet
Digital wallet
 
Apple Pay's Obvious Value Proposition
Apple Pay's Obvious Value PropositionApple Pay's Obvious Value Proposition
Apple Pay's Obvious Value Proposition
 

Similar to Network Programming in Java

Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
Mousmi Pawar
 
Application Layer and Socket Programming
Application Layer and Socket ProgrammingApplication Layer and Socket Programming
Application Layer and Socket Programming
elliando dias
 
Networking
NetworkingNetworking
Networking
Tuan Ngo
 

Similar to Network Programming in Java (20)

Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Unit 8 Java
Unit 8 JavaUnit 8 Java
Unit 8 Java
 
Networking
NetworkingNetworking
Networking
 
Sockets
SocketsSockets
Sockets
 
28 networking
28  networking28  networking
28 networking
 
Md13 networking
Md13 networkingMd13 networking
Md13 networking
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
 
Application Layer and Socket Programming
Application Layer and Socket ProgrammingApplication Layer and Socket Programming
Application Layer and Socket Programming
 
Unit-4 networking basics in java
Unit-4 networking basics in javaUnit-4 networking basics in java
Unit-4 networking basics in java
 
Java 1
Java 1Java 1
Java 1
 
Networking & Socket Programming In Java
Networking & Socket Programming In JavaNetworking & Socket Programming In Java
Networking & Socket Programming In Java
 
Networking in Java
Networking in JavaNetworking in Java
Networking in Java
 
Lecture25
Lecture25Lecture25
Lecture25
 
Socket Programming by Rajkumar Buyya
Socket Programming by Rajkumar BuyyaSocket Programming by Rajkumar Buyya
Socket Programming by Rajkumar Buyya
 
A.java
A.javaA.java
A.java
 
Socket programming
Socket programmingSocket programming
Socket programming
 
Networking
NetworkingNetworking
Networking
 
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriyaIPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
 
Lan chat system
Lan chat systemLan chat system
Lan chat system
 

More from Tushar B Kute

More from Tushar B Kute (20)

Apache Pig: A big data processor
Apache Pig: A big data processorApache Pig: A big data processor
Apache Pig: A big data processor
 
01 Introduction to Android
01 Introduction to Android01 Introduction to Android
01 Introduction to Android
 
Ubuntu OS and it's Flavours
Ubuntu OS and it's FlavoursUbuntu OS and it's Flavours
Ubuntu OS and it's Flavours
 
Install Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. KuteInstall Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. Kute
 
Install Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. KuteInstall Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. Kute
 
Share File easily between computers using sftp
Share File easily between computers using sftpShare File easily between computers using sftp
Share File easily between computers using sftp
 
Signal Handling in Linux
Signal Handling in LinuxSignal Handling in Linux
Signal Handling in Linux
 
Implementation of FIFO in Linux
Implementation of FIFO in LinuxImplementation of FIFO in Linux
Implementation of FIFO in Linux
 
Implementation of Pipe in Linux
Implementation of Pipe in LinuxImplementation of Pipe in Linux
Implementation of Pipe in Linux
 
Basic Multithreading using Posix Threads
Basic Multithreading using Posix ThreadsBasic Multithreading using Posix Threads
Basic Multithreading using Posix Threads
 
Part 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxPart 04 Creating a System Call in Linux
Part 04 Creating a System Call in Linux
 
Part 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxPart 03 File System Implementation in Linux
Part 03 File System Implementation in Linux
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
 
Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)
 
Open source applications softwares
Open source applications softwaresOpen source applications softwares
Open source applications softwares
 
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
 
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteUnit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
 
Technical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrcTechnical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrc
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Recently uploaded (20)

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 

Network Programming in Java

  • 1. Java Network Programming Tushar B. Kute Assistant Professor Department of Information Technology, Sandip Institute of Technology and Research Centre, Nashik.
  • 2.
  • 3. “ The Network is Computer” Internet Server PC client Local Area Network PDA
  • 4.
  • 5. Elements of C-S Computing Network Request Result a client, a server, and network Client Server Client machine Server machine
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24. Java Sockets ServerSocket(1234) Socket(“128.250.25.158”, 1234) Output/write stream Input/read stream It can be host_name like “books.google.com” Client Server
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54. TCP vs. UDP No. TCP UDP 1 This Connection oriented protocol This is connection-less protocol 2 The TCP connection is byte stream The UDP connection is a message stream 3 It does not support multicasting and broadcasting It supports broadcasting 4 It provides error control and flow control The error control and flow control is not provided 5 TCP supports full duplex transmission UDP does not support full duplex transmission 6 It is reliable service of data transmission This is an unreliable service of data transmission 7 The TCP packet is called as segment The UDP packet is called as user datagram.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.