SlideShare a Scribd company logo
Advanced Programming
Networking in Java
Gera
2020
1
Networking in Java
•The Java programming language is supposed to
become the premier tool for connecting
computers over the Internet and corporate
intranets and, in this realm, Java mostly lives up to
the hype.
•If you are accustomed to programming network
connections in C or C++, you will be pleasantly
surprised at how easy it is to program them in the
Java programming language.
2
Networking in Java…
•The term 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.
•The java.net package of the J2SE APIs contains a
collection of classes and interfaces that provide
the low-level communication details, allowing you
to write programs that focus on solving the
problem at hand.
3
Networking in Java…
• The java.net package provides support for the two
common network protocols:
• TCP: TCP stands for Transmission Control Protocol,
which allows for reliable communication between
two applications. TCP is typically used over the
Internet Protocol, which is referred to as TCP/IP.
• UDP: UDP stands for User Datagram Protocol, a
connection-less protocol that allows for packets of
data to be transmitted between applications.
4
Implementing Servers in Java
• To implement a basic network client that receives data from the
Net, let’s implement a simple server that can send information
out to the Net.
• Once you start the server program, it waits for some client to
attach to its port.
• We chose port number 8189, which is not used by any of the
standard services.
• The ServerSocket class is used to establish a socket.
• In our case, the command establishes a server that monitors port
8189
• ServerSocket s = new ServerSocker (8189);
5
Socket Programming
•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.
• The client and server can now communicate by
writing to and reading from the socket. 6
Socket Programming…
• The java.net.Socket class represents a socket, and the
java.net.ServerSocket class provides a mechanism for the
server program to listen for clients and establish
connections with them.
• The following steps occur when establishing a TCP
connection between two computers using sockets:
• The server instantiates a ServerSocket object, denoting which
port number communication is to occur on.
• The server invokes the accept() method of the ServerSocket
class. This method waits until a client connects to the server
on the given port.
7
Socket Programming…
• After the server is waiting, a client instantiates a Socket
object, specifying the server name and port number to
connect to.
• The constructor of the Socket class attempts to connect the
client to the specified server and port number. If
communication is established, the client now has a Socket
object capable of communicating with the server.
• On the server side, the accept() method returns a reference to
a new socket on the server that is connected to the client's
socket.
8
Socket Programming…
• After the connections are established, communication
can occur using I/O streams. Each socket has both an
OutputStream and an InputStream. The client's
OutputStream is connected to the server's InputStream,
and the client's InputStream is connected to the server's
OutputStream.
• The following GreetingServer program is an example of a
server application that uses the Socket class to listen for
clients on a port number specified by a command-line
argument:
9
Manipulating URLs…
10
Compile client and Server and then start server as follows:
Manipulating URLs
• The Internet offers many protocols.
• The Hypertext Transfer Protocol (HTTP), which forms the basis of
the World Wide Web, uses URIs (Uniform Resource Identifiers)
to identify data on the Internet.
• URIs that specify the locations of documents are called URLs
(Uniform Resource Locators).
• Common URLs refer to files or directories and can reference
objects that perform complex tasks, such as database lookups
and Internet searches.
• If you know the HTTP URL of a publicly available HTML document
anywhere on the web, you can access it through HTTP.
11
Manipulating URLs…
•Java makes it easy to manipulate URLs.
•When you use a URL that refers to the exact
location of a resource (e.g., a web page) as an
argument to the showDocument method of
interface AppletContext, the browser in which
the applet is executing will display that resource.
12
Manipulating URLs…
URL Processing
•URL stands for Uniform Resource Locator and
represents a resource on the World Wide Web,
such as a Web page or FTP directory.
•The following URLDemo program demonstrates
the various parts of a URL.
•A URL is entered on the command line, and the
URLDemo program outputs each part of the given
URL. 13
Manipulating URLs…
14
A sample run of the program would produce the
following result:
Manipulating URLs…
URL Connections Class Methods:
•The openConnection() method returns a
java.net.URLConnection, an abstract class whose
subclasses represent the various types of URL
connections.
• The following URLConnectionDemo program connects to
a URL entered from the command line.
• If the URL represents an HTTP resource, the connection is
cast to HttpURLConnection, and the data in the resource
is read one line at a time. 15
Manipulating URLs…
16
A sample run of the program would produce the
following result:
References
➢S. Horstmann and Gary Cornell, Core Java 2 – Volume II-
Advanced Features, Sun Microsystems Press
➢Harvey M. Deitel and Paul J. Deitel, Java How to
Program, Deitel & Associates
➢Tutorials Point “Java Tutorial,” tutorialspoint.com
17
Gerabirhan Paulos
ToCourseInfo@gmail.com

More Related Content

What's hot (20)

Android Layout.pptx
Android Layout.pptxAndroid Layout.pptx
Android Layout.pptx
vishal choudhary
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
BHUVIJAYAVELU
 
RichControl in Asp.net
RichControl in Asp.netRichControl in Asp.net
RichControl in Asp.net
Bhumivaghasiya
 
Java Beans
Java BeansJava Beans
Java Beans
Ankit Desai
 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net framework
Then Murugeshwari
 
Network programming in java - PPT
Network programming in java - PPTNetwork programming in java - PPT
Network programming in java - PPT
kamal kotecha
 
Java beans
Java beansJava beans
Java beans
Rajkiran Mummadi
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
Haldia Institute of Technology
 
Java string handling
Java string handlingJava string handling
Java string handling
Salman Khan
 
01 xml document structure
01 xml document structure01 xml document structure
01 xml document structure
Baskarkncet
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
VisualBee.com
 
Assemblies
AssembliesAssemblies
Assemblies
Janas Khan
 
Inter thread communication
Inter thread communicationInter thread communication
Inter thread communication
subash andey
 
serializability in dbms
serializability in dbmsserializability in dbms
serializability in dbms
Saranya Natarajan
 
Java Networking
Java NetworkingJava Networking
Java Networking
Sunil OS
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
sandeep54552
 
Tcp/ip server sockets
Tcp/ip server socketsTcp/ip server sockets
Tcp/ip server sockets
rajshreemuthiah
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
Poojith Chowdhary
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
BG Java EE Course
 
Transport layer protocol
Transport layer protocolTransport layer protocol
Transport layer protocol
N.Jagadish Kumar
 

Similar to Networking in java, Advanced programming (20)

Java Network Programming.pptx
Java Network Programming.pptxJava Network Programming.pptx
Java Network Programming.pptx
RoshniSundrani
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
Mousmi Pawar
 
Socket programming
Socket programmingSocket programming
Socket programming
Padmavathione
 
Advanced Java Topics
Advanced Java TopicsAdvanced Java Topics
Advanced Java Topics
Salahaddin University-Erbil
 
Socket Programming by Rajkumar Buyya
Socket Programming by Rajkumar BuyyaSocket Programming by Rajkumar Buyya
Socket Programming by Rajkumar Buyya
iDhawalVaja
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
5_6278455688045789623.pptx
5_6278455688045789623.pptx5_6278455688045789623.pptx
5_6278455688045789623.pptx
EliasPetros
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat application
Samsil Arefin
 
Networking.pptx
Networking.pptxNetworking.pptx
Networking.pptx
Esubesisay
 
28 networking
28  networking28  networking
28 networking
Ravindra Rathore
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
Nitish Nagar
 
socket-programming.pptx
socket-programming.pptxsocket-programming.pptx
socket-programming.pptx
RubenAssandja
 
Sockets
SocketsSockets
Sockets
sivindia
 
How a network connection is created A network connection is initi.pdf
How a network connection is created A network connection is initi.pdfHow a network connection is created A network connection is initi.pdf
How a network connection is created A network connection is initi.pdf
arccreation001
 
Java socket programming
Java socket programmingJava socket programming
Java socket programming
Mohammed Abdalla Youssif
 
A.java
A.javaA.java
A.java
JahnaviBhagat
 
sockets SMTP Bmsce ppt information science and engineering
sockets SMTP Bmsce ppt information science and engineeringsockets SMTP Bmsce ppt information science and engineering
sockets SMTP Bmsce ppt information science and engineering
UtkarshaMahajan6
 
Java networking
Java networkingJava networking
Java networking
Arati Gadgil
 
Multi user chat system using java
Multi user chat system using javaMulti user chat system using java
Multi user chat system using java
Akhil Goutham Kotini
 
Socket
SocketSocket
Socket
Amandeep Kaur
 
Java Network Programming.pptx
Java Network Programming.pptxJava Network Programming.pptx
Java Network Programming.pptx
RoshniSundrani
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
Mousmi Pawar
 
Socket Programming by Rajkumar Buyya
Socket Programming by Rajkumar BuyyaSocket Programming by Rajkumar Buyya
Socket Programming by Rajkumar Buyya
iDhawalVaja
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
5_6278455688045789623.pptx
5_6278455688045789623.pptx5_6278455688045789623.pptx
5_6278455688045789623.pptx
EliasPetros
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat application
Samsil Arefin
 
Networking.pptx
Networking.pptxNetworking.pptx
Networking.pptx
Esubesisay
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
Nitish Nagar
 
socket-programming.pptx
socket-programming.pptxsocket-programming.pptx
socket-programming.pptx
RubenAssandja
 
How a network connection is created A network connection is initi.pdf
How a network connection is created A network connection is initi.pdfHow a network connection is created A network connection is initi.pdf
How a network connection is created A network connection is initi.pdf
arccreation001
 
sockets SMTP Bmsce ppt information science and engineering
sockets SMTP Bmsce ppt information science and engineeringsockets SMTP Bmsce ppt information science and engineering
sockets SMTP Bmsce ppt information science and engineering
UtkarshaMahajan6
 

More from Gera Paulos (20)

Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
Gera Paulos
 
Multi Threading Concept (Advanced programming)
Multi Threading Concept (Advanced programming)Multi Threading Concept (Advanced programming)
Multi Threading Concept (Advanced programming)
Gera Paulos
 
Java Database Connectivity (Advanced programming)
Java Database Connectivity (Advanced programming)Java Database Connectivity (Advanced programming)
Java Database Connectivity (Advanced programming)
Gera Paulos
 
Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)
Gera Paulos
 
Advanced programming ch2
Advanced programming ch2Advanced programming ch2
Advanced programming ch2
Gera Paulos
 
Advanced programming ch1
Advanced programming ch1Advanced programming ch1
Advanced programming ch1
Gera Paulos
 
Image restoration and enhancement #2
Image restoration and enhancement #2 Image restoration and enhancement #2
Image restoration and enhancement #2
Gera Paulos
 
Introduction to digital image processing #1
Introduction to digital image processing #1Introduction to digital image processing #1
Introduction to digital image processing #1
Gera Paulos
 
Implement maintenance procedures
Implement maintenance proceduresImplement maintenance procedures
Implement maintenance procedures
Gera Paulos
 
Maintain equipment and consumables
Maintain equipment and consumablesMaintain equipment and consumables
Maintain equipment and consumables
Gera Paulos
 
Care for network and computer hardware
Care for network and computer hardwareCare for network and computer hardware
Care for network and computer hardware
Gera Paulos
 
Update and document operational procedures
Update and document operational proceduresUpdate and document operational procedures
Update and document operational procedures
Gera Paulos
 
Apply quality control
Apply quality controlApply quality control
Apply quality control
Gera Paulos
 
Monitoring implementation of work plan
Monitoring implementation of work planMonitoring implementation of work plan
Monitoring implementation of work plan
Gera Paulos
 
Provide first level remote help desk support
Provide first level remote help desk supportProvide first level remote help desk support
Provide first level remote help desk support
Gera Paulos
 
Configuring and administrate server
Configuring and administrate serverConfiguring and administrate server
Configuring and administrate server
Gera Paulos
 
Identifying and resolving network problems
Identifying and resolving network problemsIdentifying and resolving network problems
Identifying and resolving network problems
Gera Paulos
 
Conduct / facilitate user training
Conduct / facilitate user trainingConduct / facilitate user training
Conduct / facilitate user training
Gera Paulos
 
Monitor and administer system and network
Monitor and administer system and network Monitor and administer system and network
Monitor and administer system and network
Gera Paulos
 
Creating technical documents
Creating technical documentsCreating technical documents
Creating technical documents
Gera Paulos
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
Gera Paulos
 
Multi Threading Concept (Advanced programming)
Multi Threading Concept (Advanced programming)Multi Threading Concept (Advanced programming)
Multi Threading Concept (Advanced programming)
Gera Paulos
 
Java Database Connectivity (Advanced programming)
Java Database Connectivity (Advanced programming)Java Database Connectivity (Advanced programming)
Java Database Connectivity (Advanced programming)
Gera Paulos
 
Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)
Gera Paulos
 
Advanced programming ch2
Advanced programming ch2Advanced programming ch2
Advanced programming ch2
Gera Paulos
 
Advanced programming ch1
Advanced programming ch1Advanced programming ch1
Advanced programming ch1
Gera Paulos
 
Image restoration and enhancement #2
Image restoration and enhancement #2 Image restoration and enhancement #2
Image restoration and enhancement #2
Gera Paulos
 
Introduction to digital image processing #1
Introduction to digital image processing #1Introduction to digital image processing #1
Introduction to digital image processing #1
Gera Paulos
 
Implement maintenance procedures
Implement maintenance proceduresImplement maintenance procedures
Implement maintenance procedures
Gera Paulos
 
Maintain equipment and consumables
Maintain equipment and consumablesMaintain equipment and consumables
Maintain equipment and consumables
Gera Paulos
 
Care for network and computer hardware
Care for network and computer hardwareCare for network and computer hardware
Care for network and computer hardware
Gera Paulos
 
Update and document operational procedures
Update and document operational proceduresUpdate and document operational procedures
Update and document operational procedures
Gera Paulos
 
Apply quality control
Apply quality controlApply quality control
Apply quality control
Gera Paulos
 
Monitoring implementation of work plan
Monitoring implementation of work planMonitoring implementation of work plan
Monitoring implementation of work plan
Gera Paulos
 
Provide first level remote help desk support
Provide first level remote help desk supportProvide first level remote help desk support
Provide first level remote help desk support
Gera Paulos
 
Configuring and administrate server
Configuring and administrate serverConfiguring and administrate server
Configuring and administrate server
Gera Paulos
 
Identifying and resolving network problems
Identifying and resolving network problemsIdentifying and resolving network problems
Identifying and resolving network problems
Gera Paulos
 
Conduct / facilitate user training
Conduct / facilitate user trainingConduct / facilitate user training
Conduct / facilitate user training
Gera Paulos
 
Monitor and administer system and network
Monitor and administer system and network Monitor and administer system and network
Monitor and administer system and network
Gera Paulos
 
Creating technical documents
Creating technical documentsCreating technical documents
Creating technical documents
Gera Paulos
 

Recently uploaded (20)

Agentic AI, A Business Overview - May 2025
Agentic AI, A Business Overview - May 2025Agentic AI, A Business Overview - May 2025
Agentic AI, A Business Overview - May 2025
Peter Morgan
 
Introducing High Availability: Business Continuity for Every NAS User
Introducing High Availability: Business Continuity for Every NAS UserIntroducing High Availability: Business Continuity for Every NAS User
Introducing High Availability: Business Continuity for Every NAS User
QNAP Marketing
 
Planetek Italia Corporate Profile Brochure
Planetek Italia Corporate Profile BrochurePlanetek Italia Corporate Profile Brochure
Planetek Italia Corporate Profile Brochure
Planetek Italia Srl
 
Managing Geospatial Open Data Serverlessly [AWS Community Day CH 2025]
Managing Geospatial Open Data Serverlessly [AWS Community Day CH 2025]Managing Geospatial Open Data Serverlessly [AWS Community Day CH 2025]
Managing Geospatial Open Data Serverlessly [AWS Community Day CH 2025]
Chris Bingham
 
NVIDIA’s Enterprise AI Factory and Blueprints_ Paving the Way for Smart, Scal...
NVIDIA’s Enterprise AI Factory and Blueprints_ Paving the Way for Smart, Scal...NVIDIA’s Enterprise AI Factory and Blueprints_ Paving the Way for Smart, Scal...
NVIDIA’s Enterprise AI Factory and Blueprints_ Paving the Way for Smart, Scal...
derrickjswork
 
Interactive SQL: SQL, Features of SQL, DDL & DML
Interactive SQL: SQL, Features of SQL,  DDL & DMLInteractive SQL: SQL, Features of SQL,  DDL & DML
Interactive SQL: SQL, Features of SQL, DDL & DML
IsakkiDeviP
 
AI needs Hybrid Cloud - TEC conference 2025.pptx
AI needs Hybrid Cloud - TEC conference 2025.pptxAI needs Hybrid Cloud - TEC conference 2025.pptx
AI needs Hybrid Cloud - TEC conference 2025.pptx
Shikha Srivastava
 
"AI in the browser: predicting user actions in real time with TensorflowJS", ...
"AI in the browser: predicting user actions in real time with TensorflowJS", ..."AI in the browser: predicting user actions in real time with TensorflowJS", ...
"AI in the browser: predicting user actions in real time with TensorflowJS", ...
Fwdays
 
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PCWondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Mudasir
 
TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc Webinar: Cross-Border Data Transfers in 2025TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc
 
Four Principles for Physically Interpretable World Models
Four Principles for Physically Interpretable World ModelsFour Principles for Physically Interpretable World Models
Four Principles for Physically Interpretable World Models
Ivan Ruchkin
 
Pushing the Limits: CloudStack at 25K Hosts
Pushing the Limits: CloudStack at 25K HostsPushing the Limits: CloudStack at 25K Hosts
Pushing the Limits: CloudStack at 25K Hosts
ShapeBlue
 
Reducing Bugs With Static Code Analysis php tek 2025
Reducing Bugs With Static Code Analysis php tek 2025Reducing Bugs With Static Code Analysis php tek 2025
Reducing Bugs With Static Code Analysis php tek 2025
Scott Keck-Warren
 
Dr Schwarzkopf presentation on STKI Summit A
Dr Schwarzkopf presentation on STKI Summit ADr Schwarzkopf presentation on STKI Summit A
Dr Schwarzkopf presentation on STKI Summit A
Dr. Jimmy Schwarzkopf
 
Building Connected Agents: An Overview of Google's ADK and A2A Protocol
Building Connected Agents:  An Overview of Google's ADK and A2A ProtocolBuilding Connected Agents:  An Overview of Google's ADK and A2A Protocol
Building Connected Agents: An Overview of Google's ADK and A2A Protocol
Suresh Peiris
 
The fundamental misunderstanding in Team Topologies
The fundamental misunderstanding in Team TopologiesThe fundamental misunderstanding in Team Topologies
The fundamental misunderstanding in Team Topologies
Patricia Aas
 
CloudStack + KVM: Your Local Cloud Lab
CloudStack + KVM:   Your Local Cloud LabCloudStack + KVM:   Your Local Cloud Lab
CloudStack + KVM: Your Local Cloud Lab
ShapeBlue
 
Outdated Tech, Invisible Expenses – How Data Silos Undermine Operational Effi...
Outdated Tech, Invisible Expenses – How Data Silos Undermine Operational Effi...Outdated Tech, Invisible Expenses – How Data Silos Undermine Operational Effi...
Outdated Tech, Invisible Expenses – How Data Silos Undermine Operational Effi...
Precisely
 
Storage Setup for LINSTOR/DRBD/CloudStack
Storage Setup for LINSTOR/DRBD/CloudStackStorage Setup for LINSTOR/DRBD/CloudStack
Storage Setup for LINSTOR/DRBD/CloudStack
ShapeBlue
 
A simple Introduction to Algorithmic Fairness
A simple Introduction to Algorithmic FairnessA simple Introduction to Algorithmic Fairness
A simple Introduction to Algorithmic Fairness
Paolo Missier
 
Agentic AI, A Business Overview - May 2025
Agentic AI, A Business Overview - May 2025Agentic AI, A Business Overview - May 2025
Agentic AI, A Business Overview - May 2025
Peter Morgan
 
Introducing High Availability: Business Continuity for Every NAS User
Introducing High Availability: Business Continuity for Every NAS UserIntroducing High Availability: Business Continuity for Every NAS User
Introducing High Availability: Business Continuity for Every NAS User
QNAP Marketing
 
Planetek Italia Corporate Profile Brochure
Planetek Italia Corporate Profile BrochurePlanetek Italia Corporate Profile Brochure
Planetek Italia Corporate Profile Brochure
Planetek Italia Srl
 
Managing Geospatial Open Data Serverlessly [AWS Community Day CH 2025]
Managing Geospatial Open Data Serverlessly [AWS Community Day CH 2025]Managing Geospatial Open Data Serverlessly [AWS Community Day CH 2025]
Managing Geospatial Open Data Serverlessly [AWS Community Day CH 2025]
Chris Bingham
 
NVIDIA’s Enterprise AI Factory and Blueprints_ Paving the Way for Smart, Scal...
NVIDIA’s Enterprise AI Factory and Blueprints_ Paving the Way for Smart, Scal...NVIDIA’s Enterprise AI Factory and Blueprints_ Paving the Way for Smart, Scal...
NVIDIA’s Enterprise AI Factory and Blueprints_ Paving the Way for Smart, Scal...
derrickjswork
 
Interactive SQL: SQL, Features of SQL, DDL & DML
Interactive SQL: SQL, Features of SQL,  DDL & DMLInteractive SQL: SQL, Features of SQL,  DDL & DML
Interactive SQL: SQL, Features of SQL, DDL & DML
IsakkiDeviP
 
AI needs Hybrid Cloud - TEC conference 2025.pptx
AI needs Hybrid Cloud - TEC conference 2025.pptxAI needs Hybrid Cloud - TEC conference 2025.pptx
AI needs Hybrid Cloud - TEC conference 2025.pptx
Shikha Srivastava
 
"AI in the browser: predicting user actions in real time with TensorflowJS", ...
"AI in the browser: predicting user actions in real time with TensorflowJS", ..."AI in the browser: predicting user actions in real time with TensorflowJS", ...
"AI in the browser: predicting user actions in real time with TensorflowJS", ...
Fwdays
 
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PCWondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Mudasir
 
TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc Webinar: Cross-Border Data Transfers in 2025TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc
 
Four Principles for Physically Interpretable World Models
Four Principles for Physically Interpretable World ModelsFour Principles for Physically Interpretable World Models
Four Principles for Physically Interpretable World Models
Ivan Ruchkin
 
Pushing the Limits: CloudStack at 25K Hosts
Pushing the Limits: CloudStack at 25K HostsPushing the Limits: CloudStack at 25K Hosts
Pushing the Limits: CloudStack at 25K Hosts
ShapeBlue
 
Reducing Bugs With Static Code Analysis php tek 2025
Reducing Bugs With Static Code Analysis php tek 2025Reducing Bugs With Static Code Analysis php tek 2025
Reducing Bugs With Static Code Analysis php tek 2025
Scott Keck-Warren
 
Dr Schwarzkopf presentation on STKI Summit A
Dr Schwarzkopf presentation on STKI Summit ADr Schwarzkopf presentation on STKI Summit A
Dr Schwarzkopf presentation on STKI Summit A
Dr. Jimmy Schwarzkopf
 
Building Connected Agents: An Overview of Google's ADK and A2A Protocol
Building Connected Agents:  An Overview of Google's ADK and A2A ProtocolBuilding Connected Agents:  An Overview of Google's ADK and A2A Protocol
Building Connected Agents: An Overview of Google's ADK and A2A Protocol
Suresh Peiris
 
The fundamental misunderstanding in Team Topologies
The fundamental misunderstanding in Team TopologiesThe fundamental misunderstanding in Team Topologies
The fundamental misunderstanding in Team Topologies
Patricia Aas
 
CloudStack + KVM: Your Local Cloud Lab
CloudStack + KVM:   Your Local Cloud LabCloudStack + KVM:   Your Local Cloud Lab
CloudStack + KVM: Your Local Cloud Lab
ShapeBlue
 
Outdated Tech, Invisible Expenses – How Data Silos Undermine Operational Effi...
Outdated Tech, Invisible Expenses – How Data Silos Undermine Operational Effi...Outdated Tech, Invisible Expenses – How Data Silos Undermine Operational Effi...
Outdated Tech, Invisible Expenses – How Data Silos Undermine Operational Effi...
Precisely
 
Storage Setup for LINSTOR/DRBD/CloudStack
Storage Setup for LINSTOR/DRBD/CloudStackStorage Setup for LINSTOR/DRBD/CloudStack
Storage Setup for LINSTOR/DRBD/CloudStack
ShapeBlue
 
A simple Introduction to Algorithmic Fairness
A simple Introduction to Algorithmic FairnessA simple Introduction to Algorithmic Fairness
A simple Introduction to Algorithmic Fairness
Paolo Missier
 

Networking in java, Advanced programming

  • 2. Networking in Java •The Java programming language is supposed to become the premier tool for connecting computers over the Internet and corporate intranets and, in this realm, Java mostly lives up to the hype. •If you are accustomed to programming network connections in C or C++, you will be pleasantly surprised at how easy it is to program them in the Java programming language. 2
  • 3. Networking in Java… •The term 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. •The java.net package of the J2SE APIs contains a collection of classes and interfaces that provide the low-level communication details, allowing you to write programs that focus on solving the problem at hand. 3
  • 4. Networking in Java… • The java.net package provides support for the two common network protocols: • TCP: TCP stands for Transmission Control Protocol, which allows for reliable communication between two applications. TCP is typically used over the Internet Protocol, which is referred to as TCP/IP. • UDP: UDP stands for User Datagram Protocol, a connection-less protocol that allows for packets of data to be transmitted between applications. 4
  • 5. Implementing Servers in Java • To implement a basic network client that receives data from the Net, let’s implement a simple server that can send information out to the Net. • Once you start the server program, it waits for some client to attach to its port. • We chose port number 8189, which is not used by any of the standard services. • The ServerSocket class is used to establish a socket. • In our case, the command establishes a server that monitors port 8189 • ServerSocket s = new ServerSocker (8189); 5
  • 6. Socket Programming •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. • The client and server can now communicate by writing to and reading from the socket. 6
  • 7. Socket Programming… • The java.net.Socket class represents a socket, and the java.net.ServerSocket class provides a mechanism for the server program to listen for clients and establish connections with them. • The following steps occur when establishing a TCP connection between two computers using sockets: • The server instantiates a ServerSocket object, denoting which port number communication is to occur on. • The server invokes the accept() method of the ServerSocket class. This method waits until a client connects to the server on the given port. 7
  • 8. Socket Programming… • After the server is waiting, a client instantiates a Socket object, specifying the server name and port number to connect to. • The constructor of the Socket class attempts to connect the client to the specified server and port number. If communication is established, the client now has a Socket object capable of communicating with the server. • On the server side, the accept() method returns a reference to a new socket on the server that is connected to the client's socket. 8
  • 9. Socket Programming… • After the connections are established, communication can occur using I/O streams. Each socket has both an OutputStream and an InputStream. The client's OutputStream is connected to the server's InputStream, and the client's InputStream is connected to the server's OutputStream. • The following GreetingServer program is an example of a server application that uses the Socket class to listen for clients on a port number specified by a command-line argument: 9
  • 10. Manipulating URLs… 10 Compile client and Server and then start server as follows:
  • 11. Manipulating URLs • The Internet offers many protocols. • The Hypertext Transfer Protocol (HTTP), which forms the basis of the World Wide Web, uses URIs (Uniform Resource Identifiers) to identify data on the Internet. • URIs that specify the locations of documents are called URLs (Uniform Resource Locators). • Common URLs refer to files or directories and can reference objects that perform complex tasks, such as database lookups and Internet searches. • If you know the HTTP URL of a publicly available HTML document anywhere on the web, you can access it through HTTP. 11
  • 12. Manipulating URLs… •Java makes it easy to manipulate URLs. •When you use a URL that refers to the exact location of a resource (e.g., a web page) as an argument to the showDocument method of interface AppletContext, the browser in which the applet is executing will display that resource. 12
  • 13. Manipulating URLs… URL Processing •URL stands for Uniform Resource Locator and represents a resource on the World Wide Web, such as a Web page or FTP directory. •The following URLDemo program demonstrates the various parts of a URL. •A URL is entered on the command line, and the URLDemo program outputs each part of the given URL. 13
  • 14. Manipulating URLs… 14 A sample run of the program would produce the following result:
  • 15. Manipulating URLs… URL Connections Class Methods: •The openConnection() method returns a java.net.URLConnection, an abstract class whose subclasses represent the various types of URL connections. • The following URLConnectionDemo program connects to a URL entered from the command line. • If the URL represents an HTTP resource, the connection is cast to HttpURLConnection, and the data in the resource is read one line at a time. 15
  • 16. Manipulating URLs… 16 A sample run of the program would produce the following result:
  • 17. References ➢S. Horstmann and Gary Cornell, Core Java 2 – Volume II- Advanced Features, Sun Microsystems Press ➢Harvey M. Deitel and Paul J. Deitel, Java How to Program, Deitel & Associates ➢Tutorials Point “Java Tutorial,” tutorialspoint.com 17 Gerabirhan Paulos ToCourseInfo@gmail.com
  翻译: