SlideShare a Scribd company logo
 Roll No: 51 – 60
 Topic : Java Networking
Java Networking
 Java Networking is a concept of connecting two or more computing devices
together so that we can share resources.
 Java socket programming provides facility to share data between different
computing devices.
 A Socket is one endpoint of a two-way Connection link between two programs
running on the network.
 The socket is bound to a port number so that TCP layer can identify the
application that data is destined to be sent.
 Port number are 16 bit unsigned binary no.
 TCP: Transmission Control Protocol provides reliable communication between the
sender and receiver. TCP is used along with the Internet Protocol referred as TCP/IP.
java.net.Socket – For Client implementation
Java.net.Server.Socket – For Server implementation
 UDP: User Datagram Protocol provides a connection-less protocol service by allowing
packet of data to be transferred along two or more nodes
Public Input Stream getInputStream() Return the input stream attached with this
socket.
Public Output Stream getOutputStream() Return the output stream attached with this
socket.
Public Synchronized void close() Closes this Socket.
Public Socket accept() Return the socket and establish a connection
between client & server.
Public Synchronized void close() Closes the server socket.
 Clients and servers exchange messages in a request response it’s a messaging
pattern. The client sends a request, and the server returns a response. This
exchange of messages is an example of inter-process communication.
 To communicate, the computers must have a common language, and they must
follow rules so that both the client and the server know what to expect. The
language and rules of communication are defined in a communication.
 All client-server protocols operate in the application layer. The application-layer
protocol defines the basic patterns of the dialogue.
 When a bank customer accesses online banking services with a web browser (the
client), the client initiates a request to the bank's web server.
 The customer’s login credentials may be stored in a database, and the web server
accesses the database server as a client.
 An application server interprets the returned data and provides the output to the
web server.
 Finally, the web server returns the result to the client’s display.
 In each step of this sequence of client–server message exchanges, a computer
processes a request and returns data. This is the request-response messaging
pattern.
 This example illustrates a design pattern applicable to the client–server model:
separation of concerns.
ADVANTAGES & DISADVANTAGES OF THE
CLIENT-SERVER MODEL
Advantage Disadvantage
the client-server model is centralized
architecture helps make it easier to protect
data with access controls that are enforced
by security policies.
The client-server model is that if too many
clients simultaneously request data from the
server, it may get overloaded.
it doesn't matter if the clients and the server
are built on the same operating system
because data is transferred through client-
server protocols that are platform-agnostic.
In addition to causing network congestion,
too many requests may result in a denial of
service.
import java.io.*;
import java.net.*;
public class MyServer {
public static void main(String[] args){
try{
ServerSocket ss=new ServerSocket(6666);
Socket s=ss.accept();//establishes connection
DataInputStream dis=new DataInputStream(s.getInputStream());
String str=(String)dis.readUTF();
System.out.println("message= "+str);
ss.close();
}catch(Exception e){System.out.println(e);}
}
}
import java.io.*;
import java.net.*;
public class MyClient {
public static void main(String[] args) {
try{
Socket s=new Socket("localhost",6666);
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
dout.writeUTF("Hello Server");
dout.flush();
dout.close();
s.close();
}catch(Exception e){System.out.println(e);}
}
}
Java Networking
Java Networking

More Related Content

PPTX
What is Network Address Translation (NAT)
PPTX
Curso Cisco CCNA - VLAN - Redes Virtuales
PPTX
Java: Regular Expression
PDF
Java Basic Oops Concept
PDF
CCNA Routing Fundamentals - EIGRP, OSPF and RIP
PDF
Huawei Switch S5700 How To - Configuring single-tag vlan mapping
PDF
Practical SAP pentesting (B-Sides San Paulo)
What is Network Address Translation (NAT)
Curso Cisco CCNA - VLAN - Redes Virtuales
Java: Regular Expression
Java Basic Oops Concept
CCNA Routing Fundamentals - EIGRP, OSPF and RIP
Huawei Switch S5700 How To - Configuring single-tag vlan mapping
Practical SAP pentesting (B-Sides San Paulo)

What's hot (20)

PPTX
Design Pattern - Factory Method Pattern
PPTX
CCNA Product Overview.pptx
PDF
Dependency injection for beginners
PDF
IOS Cisco - Cheat sheets
PPTX
Sql injection in cybersecurity
PPTX
WLAN Attacks and Protection
PPTX
Java class,object,method introduction
PDF
Wi-fi Hacking
PPTX
Network address translation
PDF
Mise en place d’un système de détection
PPTX
ENSA_Module_8.pptx
PDF
Javapolymorphism
PPTX
Inheritance in c++
PPT
Ip addressing classless
PDF
Protocoles SSL/TLS
PPTX
SQL INJECTION
PDF
Apache Sling Generic Validation Framework
PDF
Configuration of bus topology in cisco packet tracer by Tanjilur Rahman
PDF
Java Thread Synchronization
PPTX
Java RMI
Design Pattern - Factory Method Pattern
CCNA Product Overview.pptx
Dependency injection for beginners
IOS Cisco - Cheat sheets
Sql injection in cybersecurity
WLAN Attacks and Protection
Java class,object,method introduction
Wi-fi Hacking
Network address translation
Mise en place d’un système de détection
ENSA_Module_8.pptx
Javapolymorphism
Inheritance in c++
Ip addressing classless
Protocoles SSL/TLS
SQL INJECTION
Apache Sling Generic Validation Framework
Configuration of bus topology in cisco packet tracer by Tanjilur Rahman
Java Thread Synchronization
Java RMI
Ad

Similar to Java Networking (20)

PDF
Chat application through client server management system project.pdf
PDF
CHAT APPLICATION THROUGH CLIENT SERVER MANAGEMENT SYSTEM PROJECT REPORT
PPT
Socket Programming - nitish nagar
PDF
Chat application throught client server project report.pdf
PPTX
Networking in Java
PPTX
Networking.pptx
PPT
Networking Java Socket Programming
PDF
How a network connection is created A network connection is initi.pdf
DOCX
Mail Server Project Report
PPT
Java networking
PPTX
Client server chat application
PPTX
COMPLEXITY CHAPTER 4 LECTURE FOR FOURTH YEAR .pptx
PPTX
Chapter 4
PPTX
Java seminar.pptx
PPT
Unit 8 Java
PPTX
Chapter 4--converted.pptx
PPT
Advanced Java Topics
PPT
Java Networking
PPTX
Java Network Programming.pptx
PDF
Chap 1 Network Theory & Java Overview
Chat application through client server management system project.pdf
CHAT APPLICATION THROUGH CLIENT SERVER MANAGEMENT SYSTEM PROJECT REPORT
Socket Programming - nitish nagar
Chat application throught client server project report.pdf
Networking in Java
Networking.pptx
Networking Java Socket Programming
How a network connection is created A network connection is initi.pdf
Mail Server Project Report
Java networking
Client server chat application
COMPLEXITY CHAPTER 4 LECTURE FOR FOURTH YEAR .pptx
Chapter 4
Java seminar.pptx
Unit 8 Java
Chapter 4--converted.pptx
Advanced Java Topics
Java Networking
Java Network Programming.pptx
Chap 1 Network Theory & Java Overview
Ad

Recently uploaded (20)

PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
master seminar digital applications in india
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Pharma ospi slides which help in ospi learning
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
RMMM.pdf make it easy to upload and study
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Cell Types and Its function , kingdom of life
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
O7-L3 Supply Chain Operations - ICLT Program
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
O5-L3 Freight Transport Ops (International) V1.pdf
master seminar digital applications in india
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Pharma ospi slides which help in ospi learning
STATICS OF THE RIGID BODIES Hibbelers.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Supply Chain Operations Speaking Notes -ICLT Program
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
202450812 BayCHI UCSC-SV 20250812 v17.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
RMMM.pdf make it easy to upload and study
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
human mycosis Human fungal infections are called human mycosis..pptx
Cell Types and Its function , kingdom of life
Final Presentation General Medicine 03-08-2024.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra

Java Networking

  • 1.  Roll No: 51 – 60  Topic : Java Networking
  • 3.  Java Networking is a concept of connecting two or more computing devices together so that we can share resources.  Java socket programming provides facility to share data between different computing devices.
  • 4.  A Socket is one endpoint of a two-way Connection link between two programs running on the network.  The socket is bound to a port number so that TCP layer can identify the application that data is destined to be sent.  Port number are 16 bit unsigned binary no.
  • 5.  TCP: Transmission Control Protocol provides reliable communication between the sender and receiver. TCP is used along with the Internet Protocol referred as TCP/IP. java.net.Socket – For Client implementation Java.net.Server.Socket – For Server implementation  UDP: User Datagram Protocol provides a connection-less protocol service by allowing packet of data to be transferred along two or more nodes
  • 6. Public Input Stream getInputStream() Return the input stream attached with this socket. Public Output Stream getOutputStream() Return the output stream attached with this socket. Public Synchronized void close() Closes this Socket. Public Socket accept() Return the socket and establish a connection between client & server. Public Synchronized void close() Closes the server socket.
  • 7.  Clients and servers exchange messages in a request response it’s a messaging pattern. The client sends a request, and the server returns a response. This exchange of messages is an example of inter-process communication.  To communicate, the computers must have a common language, and they must follow rules so that both the client and the server know what to expect. The language and rules of communication are defined in a communication.  All client-server protocols operate in the application layer. The application-layer protocol defines the basic patterns of the dialogue.
  • 8.  When a bank customer accesses online banking services with a web browser (the client), the client initiates a request to the bank's web server.  The customer’s login credentials may be stored in a database, and the web server accesses the database server as a client.  An application server interprets the returned data and provides the output to the web server.  Finally, the web server returns the result to the client’s display.  In each step of this sequence of client–server message exchanges, a computer processes a request and returns data. This is the request-response messaging pattern.  This example illustrates a design pattern applicable to the client–server model: separation of concerns.
  • 9. ADVANTAGES & DISADVANTAGES OF THE CLIENT-SERVER MODEL Advantage Disadvantage the client-server model is centralized architecture helps make it easier to protect data with access controls that are enforced by security policies. The client-server model is that if too many clients simultaneously request data from the server, it may get overloaded. it doesn't matter if the clients and the server are built on the same operating system because data is transferred through client- server protocols that are platform-agnostic. In addition to causing network congestion, too many requests may result in a denial of service.
  • 10. import java.io.*; import java.net.*; public class MyServer { public static void main(String[] args){ try{ ServerSocket ss=new ServerSocket(6666); Socket s=ss.accept();//establishes connection DataInputStream dis=new DataInputStream(s.getInputStream()); String str=(String)dis.readUTF(); System.out.println("message= "+str); ss.close(); }catch(Exception e){System.out.println(e);} } }
  • 11. import java.io.*; import java.net.*; public class MyClient { public static void main(String[] args) { try{ Socket s=new Socket("localhost",6666); DataOutputStream dout=new DataOutputStream(s.getOutputStream()); dout.writeUTF("Hello Server"); dout.flush(); dout.close(); s.close(); }catch(Exception e){System.out.println(e);} } }