SlideShare a Scribd company logo
1 of 7
CS3135/CS2135
Object Oriented Programming (Java)
BSCS-3 / MCS-3
Lecture # 24
Network Programming
Part-1
Java Network Programming
• 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.
• IP address is a unique number assigned to a node of a network e.g. 192.168.0.1 . It is composed of
octets that range from 0 to 255. It is a logical address that can be changed.
• Protocol is a set of rules basically that is followed for communication. For example:
• TCP, FTP, Telnet, SMTP, POP etc.
• Port Number is used to uniquely identify different applications. It acts as a communication endpoint
between applications.
• The port number is associated with the IP address for communication between two applications.
• In connection-oriented protocol, acknowledgement is sent by the receiver. So it is reliable but slow.
The example of connection-oriented protocol is TCP.
• 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.
• Socket is an endpoint between two way communication.
Instructor: Tanzila Kehkashan
2
Socket Programming
• Java Socket programming can be of two types:
• Connection-oriented uses classes Socket and ServerSocket
• Connection-less.uses classes DatagramSocket and DatagramPacket
• The client in socket programming must know two information.
• IP Address of Server, and Port number.
java.net.Socket
• Socket class can be used to create a socket and to connect to a remote host.
• Socket(String, int) //host, port
• InputStream getInputStream() //returns the InputStream attached with current socket object.
• OutputStream getOutputStream() //returns the OutputStream attached with curent socket object.
• synchronized void close() //closes this socket
Instructor: Tanzila Kehkashan
3
Socket Programming
java.net.ServerSocket
• The ServerSocket class can be used to create a server socket. This object is used to accept
connections from client sockets.
• ServerSocket(int) //port
• Socket accept() //returns the socket and establish a connection between server and client.
• synchronized void close() //closes the server socket.
Instructor: Tanzila Kehkashan
4
• Run two instances of Command Prompt.
• Run server file first.
Instructor: Tanzila Kehkashan
5
• Both server and client communicates
Instructor: Tanzila Kehkashan
6
Instructor: Tanzila Kehkashan
7

More Related Content

Similar to OOP Lecture 24-Network Programming-Part1.pptx

Similar to OOP Lecture 24-Network Programming-Part1.pptx (20)

Networking in python by Rj
Networking in python by RjNetworking in python by Rj
Networking in python by Rj
 
NP-lab-manual.docx
NP-lab-manual.docxNP-lab-manual.docx
NP-lab-manual.docx
 
Basic Networking in Java
Basic Networking in JavaBasic Networking in Java
Basic Networking in Java
 
Networking.pptx
Networking.pptxNetworking.pptx
Networking.pptx
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Network Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptxNetwork Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptx
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using C
 
Chap 1 Network Theory & Java Overview
Chap 1   Network Theory & Java OverviewChap 1   Network Theory & Java Overview
Chap 1 Network Theory & Java Overview
 
28 networking
28  networking28  networking
28 networking
 
09 Systems Software Programming-Network Programming.pptx
09 Systems Software Programming-Network Programming.pptx09 Systems Software Programming-Network Programming.pptx
09 Systems Software Programming-Network Programming.pptx
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Java networking
Java networkingJava networking
Java networking
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat application
 
Network Programming Assignment Help
Network Programming Assignment HelpNetwork Programming Assignment Help
Network Programming Assignment Help
 
Lecture set 7
Lecture set 7Lecture set 7
Lecture set 7
 
Socket & Server Socket
Socket & Server SocketSocket & Server Socket
Socket & Server Socket
 
Socket programming
Socket programmingSocket programming
Socket programming
 
A.java
A.javaA.java
A.java
 
chapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhjchapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhj
 
Datacom_Section_2_-_Protocols.ppt
Datacom_Section_2_-_Protocols.pptDatacom_Section_2_-_Protocols.ppt
Datacom_Section_2_-_Protocols.ppt
 

More from Tanzila Kehkashan

OOP Lecture 25-Network Programming-Part2.pptx
OOP Lecture 25-Network Programming-Part2.pptxOOP Lecture 25-Network Programming-Part2.pptx
OOP Lecture 25-Network Programming-Part2.pptxTanzila Kehkashan
 
OOP Lecture 23-JAR Files.pptx
OOP Lecture 23-JAR Files.pptxOOP Lecture 23-JAR Files.pptx
OOP Lecture 23-JAR Files.pptxTanzila Kehkashan
 
OOP Lecture 21-Graphics, Audio.pptx
OOP Lecture 21-Graphics, Audio.pptxOOP Lecture 21-Graphics, Audio.pptx
OOP Lecture 21-Graphics, Audio.pptxTanzila Kehkashan
 
OOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptxOOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptxTanzila Kehkashan
 
OOP Lecture 19-JMenuBar.pptx
OOP Lecture 19-JMenuBar.pptxOOP Lecture 19-JMenuBar.pptx
OOP Lecture 19-JMenuBar.pptxTanzila Kehkashan
 
OOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptxOOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptxTanzila Kehkashan
 
OOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptxOOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptxTanzila Kehkashan
 
OOP Lecture 16-Math,Timer.pptx
OOP Lecture 16-Math,Timer.pptxOOP Lecture 16-Math,Timer.pptx
OOP Lecture 16-Math,Timer.pptxTanzila Kehkashan
 
OOP Lecture 15-FileHandling,JFileChooser.pptx
OOP Lecture 15-FileHandling,JFileChooser.pptxOOP Lecture 15-FileHandling,JFileChooser.pptx
OOP Lecture 15-FileHandling,JFileChooser.pptxTanzila Kehkashan
 
OOP Lecture 14-ExceptionHandling.pptx
OOP Lecture 14-ExceptionHandling.pptxOOP Lecture 14-ExceptionHandling.pptx
OOP Lecture 14-ExceptionHandling.pptxTanzila Kehkashan
 
OOP Lecture 13-Color,Font,ImageIcon.pptx
OOP Lecture 13-Color,Font,ImageIcon.pptxOOP Lecture 13-Color,Font,ImageIcon.pptx
OOP Lecture 13-Color,Font,ImageIcon.pptxTanzila Kehkashan
 
OOP Lecture 12-EventHandling2.pptx
OOP Lecture 12-EventHandling2.pptxOOP Lecture 12-EventHandling2.pptx
OOP Lecture 12-EventHandling2.pptxTanzila Kehkashan
 
OOP Lecture 11-EventHandling1.pptx
OOP Lecture 11-EventHandling1.pptxOOP Lecture 11-EventHandling1.pptx
OOP Lecture 11-EventHandling1.pptxTanzila Kehkashan
 
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptxOOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptxTanzila Kehkashan
 
OOP Lecture 9-JComboBox,JList,JPanel.pptx
OOP Lecture 9-JComboBox,JList,JPanel.pptxOOP Lecture 9-JComboBox,JList,JPanel.pptx
OOP Lecture 9-JComboBox,JList,JPanel.pptxTanzila Kehkashan
 
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptxOOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptxTanzila Kehkashan
 
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptxOOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptxTanzila Kehkashan
 
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptx
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptxOOP Lecture 6-JFrame,JScrollPane,JLabel.pptx
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptxTanzila Kehkashan
 
OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptx
OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptxOOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptx
OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptxTanzila Kehkashan
 

More from Tanzila Kehkashan (20)

OOP Lecture 25-Network Programming-Part2.pptx
OOP Lecture 25-Network Programming-Part2.pptxOOP Lecture 25-Network Programming-Part2.pptx
OOP Lecture 25-Network Programming-Part2.pptx
 
OOP Lecture 23-JAR Files.pptx
OOP Lecture 23-JAR Files.pptxOOP Lecture 23-JAR Files.pptx
OOP Lecture 23-JAR Files.pptx
 
OOP Lecture 22-JApplet.pptx
OOP Lecture 22-JApplet.pptxOOP Lecture 22-JApplet.pptx
OOP Lecture 22-JApplet.pptx
 
OOP Lecture 21-Graphics, Audio.pptx
OOP Lecture 21-Graphics, Audio.pptxOOP Lecture 21-Graphics, Audio.pptx
OOP Lecture 21-Graphics, Audio.pptx
 
OOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptxOOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptx
 
OOP Lecture 19-JMenuBar.pptx
OOP Lecture 19-JMenuBar.pptxOOP Lecture 19-JMenuBar.pptx
OOP Lecture 19-JMenuBar.pptx
 
OOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptxOOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptx
 
OOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptxOOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptx
 
OOP Lecture 16-Math,Timer.pptx
OOP Lecture 16-Math,Timer.pptxOOP Lecture 16-Math,Timer.pptx
OOP Lecture 16-Math,Timer.pptx
 
OOP Lecture 15-FileHandling,JFileChooser.pptx
OOP Lecture 15-FileHandling,JFileChooser.pptxOOP Lecture 15-FileHandling,JFileChooser.pptx
OOP Lecture 15-FileHandling,JFileChooser.pptx
 
OOP Lecture 14-ExceptionHandling.pptx
OOP Lecture 14-ExceptionHandling.pptxOOP Lecture 14-ExceptionHandling.pptx
OOP Lecture 14-ExceptionHandling.pptx
 
OOP Lecture 13-Color,Font,ImageIcon.pptx
OOP Lecture 13-Color,Font,ImageIcon.pptxOOP Lecture 13-Color,Font,ImageIcon.pptx
OOP Lecture 13-Color,Font,ImageIcon.pptx
 
OOP Lecture 12-EventHandling2.pptx
OOP Lecture 12-EventHandling2.pptxOOP Lecture 12-EventHandling2.pptx
OOP Lecture 12-EventHandling2.pptx
 
OOP Lecture 11-EventHandling1.pptx
OOP Lecture 11-EventHandling1.pptxOOP Lecture 11-EventHandling1.pptx
OOP Lecture 11-EventHandling1.pptx
 
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptxOOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
 
OOP Lecture 9-JComboBox,JList,JPanel.pptx
OOP Lecture 9-JComboBox,JList,JPanel.pptxOOP Lecture 9-JComboBox,JList,JPanel.pptx
OOP Lecture 9-JComboBox,JList,JPanel.pptx
 
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptxOOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
 
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptxOOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
 
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptx
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptxOOP Lecture 6-JFrame,JScrollPane,JLabel.pptx
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptx
 
OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptx
OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptxOOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptx
OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptx
 

Recently uploaded

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 

Recently uploaded (20)

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 

OOP Lecture 24-Network Programming-Part1.pptx

  • 1. CS3135/CS2135 Object Oriented Programming (Java) BSCS-3 / MCS-3 Lecture # 24 Network Programming Part-1
  • 2. Java Network Programming • 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. • IP address is a unique number assigned to a node of a network e.g. 192.168.0.1 . It is composed of octets that range from 0 to 255. It is a logical address that can be changed. • Protocol is a set of rules basically that is followed for communication. For example: • TCP, FTP, Telnet, SMTP, POP etc. • Port Number is used to uniquely identify different applications. It acts as a communication endpoint between applications. • The port number is associated with the IP address for communication between two applications. • In connection-oriented protocol, acknowledgement is sent by the receiver. So it is reliable but slow. The example of connection-oriented protocol is TCP. • 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. • Socket is an endpoint between two way communication. Instructor: Tanzila Kehkashan 2
  • 3. Socket Programming • Java Socket programming can be of two types: • Connection-oriented uses classes Socket and ServerSocket • Connection-less.uses classes DatagramSocket and DatagramPacket • The client in socket programming must know two information. • IP Address of Server, and Port number. java.net.Socket • Socket class can be used to create a socket and to connect to a remote host. • Socket(String, int) //host, port • InputStream getInputStream() //returns the InputStream attached with current socket object. • OutputStream getOutputStream() //returns the OutputStream attached with curent socket object. • synchronized void close() //closes this socket Instructor: Tanzila Kehkashan 3
  • 4. Socket Programming java.net.ServerSocket • The ServerSocket class can be used to create a server socket. This object is used to accept connections from client sockets. • ServerSocket(int) //port • Socket accept() //returns the socket and establish a connection between server and client. • synchronized void close() //closes the server socket. Instructor: Tanzila Kehkashan 4
  • 5. • Run two instances of Command Prompt. • Run server file first. Instructor: Tanzila Kehkashan 5
  • 6. • Both server and client communicates Instructor: Tanzila Kehkashan 6