Network Programming
1
Network Programming
Refers to writing programs that execute across multiple devices
Advantages
Resource sharing
Centralized software management
Java Socket programming
Is used for communication between the applications running on different JRE
Socket class
A socket is an end point for communication between the machines
2
Is for clients and used to connect to server
Network Programming
Server Socket class
Is a listener which waits for client to connect
Java URL
URL: it points to a resource on the world wide web
URL contains:- protocol
server name or IP Address
Port number
File name or directory name
3
Network Programming
Server Socket class
Is a listener which waits for client to connect
Java URL
URL: it points to a resource on the world wide web
URL contains:- protocol
server name or IP Address
Port number
File name or directory name
4
Network Programming
Java URLConnection Class
Represents a communication link between the URL and the application
Can be used to read and write data to the specified resource referred by the URL.
Example 3
Java DatagramSocket and DatagramPacket
Classes are used for connectionless socket programming
5
RMI (Remote Method
Invocation)
It is a mechanism that allows an object residing in one system (JVM) to
access/invoke an object running on another JVM.
Used to build distributed applications
It provides remote communication between java programs.
Architecture of RMI applications
Client Server
Stub Skeleton
RRL RRL
Transport Layer Transport Layer 6
RMI (Remote Method
Invocation)
Transport layer: Connects the client and the server. It manages the existing connection
Stub: Connects is a representation (proxy) of the remote object at a client. Acts as a
gateway for the client program.
Skeleton: this is the object which resides on the server side. Stub communicates with
this skeleton to pass request to the remote object.
RMI Registry
Is a name space on which all server objects are palaced.
Each time the server creates an object it registers this object using (bind() or rebind()
methods) 7
RMI (Remote Method
Invocation)
Client Server
Invokes the method
LookUp() reBind()
RMI Registry
Creating RMI Applications (Reading
Assignment)
8