Socket Programming Slides
Socket Programming Slides
Socket
• A socket is an end-point for communication between
processes running on different machines.
Or
• A socket is one end-point of a two communication
link between two programs running on the network.
• It consists of an IP address and a port
number which uniquely identifies a running process
on a system.
Contd..
• IP Address identifies a machine and Port
No. identifies the specific application ( process ).
Client-Server Architecture
• In a client-server architecture of computing,
a server hosts a resource or a service which is
accessed by clients.
• A server is basically a machine which provides some
kind of services.
• Client will send a request to the server and server will
do some processing and send back a response to the
client.
Contd…
Request Service
Response Service
Contd..
• Example:
Apache is a Web Server providing web pages
and Internet Explorer is a web client which
request those web pages from the server.
Contd…
• Protocol
• Server name or IP Address
• Port Number
• File Name or directory name
Methods of Java URL class
• getProtocol() it returns the protocol of the
URL.
• getHost() it returns the host name of the
URL.
• getPort() it returns the Port Number of the
URL.
• getFile() it returns the file name of the
URL.
• openConnection()it returns the instance of
URLConnection i.e. associated with this URL.