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

What's hot (15)

PDF
ORM Injection
Simone Onofri
 
PPTX
IAM Deep Dive - Custom IAM Policies with Conditions
Bryant Poush
 
PPT
Chapter 9 PowerPoint
Amy McMullin
 
PPTX
Android Training (Storing data using SQLite)
Khaled Anaqwa
 
PPT
Cloud computing
Waseem Ahmed
 
PDF
[9] Firewall.pdf
lamtran367679
 
PPTX
Information System Security - Teknik Akses Kontrol
Dudy Ali
 
PPTX
Networking in Java
Tushar B Kute
 
PDF
13 mongoose
Ahmed Elbassel
 
PPTX
File transfer protocol
Vipin Rai
 
PPTX
SUBWAY-SURF-Powerpoint-Template.pptx
LazadaOne
 
PPSX
Sessions and cookies
www.netgains.org
 
PPSX
Web application security
Akhil Raj
 
PPTX
Working with NS2
chanchal214
 
PPTX
Client side scripting using Javascript
Bansari Shah
 
ORM Injection
Simone Onofri
 
IAM Deep Dive - Custom IAM Policies with Conditions
Bryant Poush
 
Chapter 9 PowerPoint
Amy McMullin
 
Android Training (Storing data using SQLite)
Khaled Anaqwa
 
Cloud computing
Waseem Ahmed
 
[9] Firewall.pdf
lamtran367679
 
Information System Security - Teknik Akses Kontrol
Dudy Ali
 
Networking in Java
Tushar B Kute
 
13 mongoose
Ahmed Elbassel
 
File transfer protocol
Vipin Rai
 
SUBWAY-SURF-Powerpoint-Template.pptx
LazadaOne
 
Sessions and cookies
www.netgains.org
 
Web application security
Akhil Raj
 
Working with NS2
chanchal214
 
Client side scripting using Javascript
Bansari Shah
 

Similar to Java Networking (20)

PPTX
Client server chat application
Samsil Arefin
 
PPTX
Java Network Programming.pptx
RoshniSundrani
 
PDF
Client server computing
StudsPlanet.com
 
PDF
Socket Programming by Rajkumar Buyya
iDhawalVaja
 
DOCX
Clientserver
Madhumithah Ilango
 
PDF
Socket programming
Padmavathione
 
PDF
How a network connection is created A network connection is initi.pdf
arccreation001
 
PDF
Lecture5 architecture styles.pdf
ssuser9d62d6
 
PPTX
Real Time Web with SignalR
Bilal Amjad
 
PPTX
ClientServer Websocket.pptx
MaxamedSheekhAmiin
 
PPTX
client server protocol
bmuhire
 
DOCX
Final Year Project IEEE 2015
TTA_TNagar
 
DOCX
Final Year IEEE Project Titles 2015
TTA_TNagar
 
PPT
Network programming in Java
Tushar B Kute
 
PPTX
CHP-4.pptx
FamiDan
 
PDF
CHAT APPLICATION THROUGH CLIENT SERVER MANAGEMENT SYSTEM PROJECT REPORT
Kamal Acharya
 
PDF
Review on tls or ssl session sharing based web cluster load balancing
eSAT Publishing House
 
PDF
Review on tls or ssl session sharing based web cluster load balancing
eSAT Journals
 
PDF
Client Server Model and Distributed Computing
Abhishek Jaisingh
 
PPT
Client Server Managment
Neeraj Dhiman
 
Client server chat application
Samsil Arefin
 
Java Network Programming.pptx
RoshniSundrani
 
Client server computing
StudsPlanet.com
 
Socket Programming by Rajkumar Buyya
iDhawalVaja
 
Clientserver
Madhumithah Ilango
 
Socket programming
Padmavathione
 
How a network connection is created A network connection is initi.pdf
arccreation001
 
Lecture5 architecture styles.pdf
ssuser9d62d6
 
Real Time Web with SignalR
Bilal Amjad
 
ClientServer Websocket.pptx
MaxamedSheekhAmiin
 
client server protocol
bmuhire
 
Final Year Project IEEE 2015
TTA_TNagar
 
Final Year IEEE Project Titles 2015
TTA_TNagar
 
Network programming in Java
Tushar B Kute
 
CHP-4.pptx
FamiDan
 
CHAT APPLICATION THROUGH CLIENT SERVER MANAGEMENT SYSTEM PROJECT REPORT
Kamal Acharya
 
Review on tls or ssl session sharing based web cluster load balancing
eSAT Publishing House
 
Review on tls or ssl session sharing based web cluster load balancing
eSAT Journals
 
Client Server Model and Distributed Computing
Abhishek Jaisingh
 
Client Server Managment
Neeraj Dhiman
 
Ad

Recently uploaded (20)

PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Ad

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);} } }