SlideShare a Scribd company logo
14
Most read
19
Most read
22
Most read
Socket programming in javaNarendranThangarajan,@naren_live,II Year, BE, CSE,SSN College of Engg, Chennai.
What started it all..Internet  has emerged as a global ubiquitous media for communicationIt has changed the way we live, learn, enjoy, communicate, interact, engage, etc.To take advantage of this, businesses are ceaselessly trying to offer their services through the internet.So a huge demand for software developers good in creating internet-enabled applications.
Client Server ApplicationsThe Web Service is provided by the server and the clients use these servicesClientRequestServerNetworkResultClient machineServer machineA client, A server, and networkThis is where sockets come in !!
SocketsIntroduced in BSD 4.1 UNIX 1981.Sockets are the endpoints of any communication over the internet.Sockets are identified by socket addresses.Socket Address = IP Address + Port Number
Why IP Address + Port number?    IP Address is of the form 10.0.0.1
    Port Number can be anything from 0 to 65,535.Destination Socket = 10.0.0.2 : 80IP Address – Choose network20.0.0.030.0.0.010.0.0.040.0.0.0
IP Address -> MAC Address – Locate the 						specific systemDestination Socket = 10.0.0.2 : 8010.0.0.110.0.0.2
Port Number – Process specificPort 10000Port 11000Port 120000
Understanding PortsGmailYMAVG UpdateOutLookExpressPort 1Port 2Port 3Port 4Transport LayerPacketPort numdataNetwork layer
Thus virtually, sockets are a connection between the two processes in different systems.Eg : Let the socket pairs be10.0.0.1 : 80 and 20.0.0.1 : 2000192.168.21.10 : 3000 and 192.168.100.1 : 6000
Networking Basics – the larger pictureApplications Layer
Standard apps
HTTP
FTP
Telnet
User apps
Transport Layer
TCP
UDP
Network Layer
IP
Link Layer
Device driversTCP STACKApplication(http,ftp,telnet,…)Transport(TCP, UDP,..)Network(IP,..)Link(device driver,..)

More Related Content

PPTX
Routing algorithm
Bushra M
 
PPTX
Network design
Amir Jafari
 
PPTX
Tcp/ip server sockets
rajshreemuthiah
 
PPTX
Hotel management system presentation
joilrahat
 
PDF
Android App Development A Complete Guide 2024.pdf
JPLoft Solutions
 
PPTX
Strategic Planning Toolkit - Framework, Best Practices and Templates
Aurelien Domont, MBA
 
PPT
Telnet
Jishnu Pradeep
 
PPTX
Hotel management system project
Mohammed Al Babeli
 
Routing algorithm
Bushra M
 
Network design
Amir Jafari
 
Tcp/ip server sockets
rajshreemuthiah
 
Hotel management system presentation
joilrahat
 
Android App Development A Complete Guide 2024.pdf
JPLoft Solutions
 
Strategic Planning Toolkit - Framework, Best Practices and Templates
Aurelien Domont, MBA
 
Hotel management system project
Mohammed Al Babeli
 

What's hot (20)

PPS
Java rmi
kamal kotecha
 
PPTX
Java socket programming
Mohammed Abdalla Youssif
 
PPT
Java Servlets
BG Java EE Course
 
PPTX
Jdbc ppt
sandeep54552
 
PPTX
Constructor in java
Pavith Gunasekara
 
PPTX
Threads in JAVA
Haldia Institute of Technology
 
PPTX
Java Beans
Ankit Desai
 
PPTX
Java - Sockets
Riccardo Cardin
 
PDF
Java Thread Synchronization
Benj Del Mundo
 
PPT
Collection Framework in java
CPD INDIA
 
PPTX
Packages in java
Elizabeth alexander
 
PDF
Java threads
Prabhakaran V M
 
PPTX
Servlets
ZainabNoorGul
 
PPTX
Networking in Java
Tushar B Kute
 
PPTX
Event handling
swapnac12
 
PPTX
Interface in java
PhD Research Scholar
 
PPTX
Hypertext transfer protocol (http)
Shimona Agarwal
 
PPT
Java Networking
Sunil OS
 
PPTX
Multithreading in java
Raghu nath
 
PPT
Java multi threading
Raja Sekhar
 
Java rmi
kamal kotecha
 
Java socket programming
Mohammed Abdalla Youssif
 
Java Servlets
BG Java EE Course
 
Jdbc ppt
sandeep54552
 
Constructor in java
Pavith Gunasekara
 
Java Beans
Ankit Desai
 
Java - Sockets
Riccardo Cardin
 
Java Thread Synchronization
Benj Del Mundo
 
Collection Framework in java
CPD INDIA
 
Packages in java
Elizabeth alexander
 
Java threads
Prabhakaran V M
 
Servlets
ZainabNoorGul
 
Networking in Java
Tushar B Kute
 
Event handling
swapnac12
 
Interface in java
PhD Research Scholar
 
Hypertext transfer protocol (http)
Shimona Agarwal
 
Java Networking
Sunil OS
 
Multithreading in java
Raghu nath
 
Java multi threading
Raja Sekhar
 
Ad

Similar to Socket programming in Java (PPTX) (20)

PDF
Socket programming using java
UC San Diego
 
PPT
Sockets
sivindia
 
PPT
Network programming in Java
Tushar B Kute
 
DOC
Socket
Amandeep Kaur
 
PPT
Socket Programming - nitish nagar
Nitish Nagar
 
PPTX
Java Network Programming.pptx
RoshniSundrani
 
PDF
Socket programming
Padmavathione
 
PPTX
Client server chat application
Samsil Arefin
 
PPTX
Chat server nitish nagar
Nitish Nagar
 
PPT
Md13 networking
Rakesh Madugula
 
PPTX
Java 1
VidyaVarshini3
 
PDF
Socket Programming by Rajkumar Buyya
iDhawalVaja
 
PPT
Client server project
yogendra kumar patel
 
PDF
Socket Programming
elliando dias
 
PPTX
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
Maulik Borsaniya
 
PPT
Network programming in Java
Tushar B Kute
 
PPT
Networking Java Socket Programming
Mousmi Pawar
 
PPT
Network Programming in Java
Tushar B Kute
 
DOCX
Mail Server Project Report
Kavita Sharma
 
Socket programming using java
UC San Diego
 
Sockets
sivindia
 
Network programming in Java
Tushar B Kute
 
Socket Programming - nitish nagar
Nitish Nagar
 
Java Network Programming.pptx
RoshniSundrani
 
Socket programming
Padmavathione
 
Client server chat application
Samsil Arefin
 
Chat server nitish nagar
Nitish Nagar
 
Md13 networking
Rakesh Madugula
 
Socket Programming by Rajkumar Buyya
iDhawalVaja
 
Client server project
yogendra kumar patel
 
Socket Programming
elliando dias
 
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
Maulik Borsaniya
 
Network programming in Java
Tushar B Kute
 
Networking Java Socket Programming
Mousmi Pawar
 
Network Programming in Java
Tushar B Kute
 
Mail Server Project Report
Kavita Sharma
 
Ad

More from UC San Diego (19)

PDF
A primer on network devices
UC San Diego
 
PDF
Datacenter traffic demand characterization
UC San Diego
 
PDF
Smart Homes, Buildings and Internet-of-things
UC San Diego
 
PDF
Social Networks analysis to characterize HIV at-risk populations - Progress a...
UC San Diego
 
PDF
eyeTalk - A system for helping people affected by motor neuron problems
UC San Diego
 
PDF
Pirc net poster
UC San Diego
 
PDF
Ajaxism
UC San Diego
 
PDF
Basic terminologies for a developer
UC San Diego
 
PDF
Fields in computer science
UC San Diego
 
PDF
Understanding computer networks
UC San Diego
 
PDF
FOSS Introduction
UC San Diego
 
PDF
Network Programming with Umit project
UC San Diego
 
PDF
Introduction to Python
UC San Diego
 
PDF
Airline reservation system db design
UC San Diego
 
PDF
Workshop on Network Security
UC San Diego
 
PDF
Routing basics
UC San Diego
 
PDF
Technology Quiz
UC San Diego
 
PDF
Android application development
UC San Diego
 
PDF
Pervasive Web Application Architecture
UC San Diego
 
A primer on network devices
UC San Diego
 
Datacenter traffic demand characterization
UC San Diego
 
Smart Homes, Buildings and Internet-of-things
UC San Diego
 
Social Networks analysis to characterize HIV at-risk populations - Progress a...
UC San Diego
 
eyeTalk - A system for helping people affected by motor neuron problems
UC San Diego
 
Pirc net poster
UC San Diego
 
Ajaxism
UC San Diego
 
Basic terminologies for a developer
UC San Diego
 
Fields in computer science
UC San Diego
 
Understanding computer networks
UC San Diego
 
FOSS Introduction
UC San Diego
 
Network Programming with Umit project
UC San Diego
 
Introduction to Python
UC San Diego
 
Airline reservation system db design
UC San Diego
 
Workshop on Network Security
UC San Diego
 
Routing basics
UC San Diego
 
Technology Quiz
UC San Diego
 
Android application development
UC San Diego
 
Pervasive Web Application Architecture
UC San Diego
 

Recently uploaded (20)

PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
FSSAI (Food Safety and Standards Authority of India) & FDA (Food and Drug Adm...
Dr. Paindla Jyothirmai
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PPTX
Trends in pediatric nursing .pptx
AneetaSharma15
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PDF
Study Material and notes for Women Empowerment
ComputerScienceSACWC
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PPTX
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
FSSAI (Food Safety and Standards Authority of India) & FDA (Food and Drug Adm...
Dr. Paindla Jyothirmai
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
Trends in pediatric nursing .pptx
AneetaSharma15
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Study Material and notes for Women Empowerment
ComputerScienceSACWC
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 

Socket programming in Java (PPTX)

  • 1. Socket programming in javaNarendranThangarajan,@naren_live,II Year, BE, CSE,SSN College of Engg, Chennai.
  • 2. What started it all..Internet has emerged as a global ubiquitous media for communicationIt has changed the way we live, learn, enjoy, communicate, interact, engage, etc.To take advantage of this, businesses are ceaselessly trying to offer their services through the internet.So a huge demand for software developers good in creating internet-enabled applications.
  • 3. Client Server ApplicationsThe Web Service is provided by the server and the clients use these servicesClientRequestServerNetworkResultClient machineServer machineA client, A server, and networkThis is where sockets come in !!
  • 4. SocketsIntroduced in BSD 4.1 UNIX 1981.Sockets are the endpoints of any communication over the internet.Sockets are identified by socket addresses.Socket Address = IP Address + Port Number
  • 5. Why IP Address + Port number? IP Address is of the form 10.0.0.1
  • 6. Port Number can be anything from 0 to 65,535.Destination Socket = 10.0.0.2 : 80IP Address – Choose network20.0.0.030.0.0.010.0.0.040.0.0.0
  • 7. IP Address -> MAC Address – Locate the specific systemDestination Socket = 10.0.0.2 : 8010.0.0.110.0.0.2
  • 8. Port Number – Process specificPort 10000Port 11000Port 120000
  • 9. Understanding PortsGmailYMAVG UpdateOutLookExpressPort 1Port 2Port 3Port 4Transport LayerPacketPort numdataNetwork layer
  • 10. Thus virtually, sockets are a connection between the two processes in different systems.Eg : Let the socket pairs be10.0.0.1 : 80 and 20.0.0.1 : 2000192.168.21.10 : 3000 and 192.168.100.1 : 6000
  • 11. Networking Basics – the larger pictureApplications Layer
  • 13. HTTP
  • 14. FTP
  • 18. TCP
  • 19. UDP
  • 21. IP
  • 23. Device driversTCP STACKApplication(http,ftp,telnet,…)Transport(TCP, UDP,..)Network(IP,..)Link(device driver,..)
  • 24. Network Basics - Where are these sockets?Applications Layer
  • 26. HTTP
  • 27. FTP
  • 33. TCP
  • 34. UDP
  • 36. IP
  • 39. Now into Socket programming..
  • 40. Socket Programming with TCPServer starts first..Server Process must be running firstServer must have created a socket which welcomes client’s connection. (Welcoming socket)Client contacts server by..Creating Client local TCP socketSpecify IP Address and port number of server process.When Client socket is created, the connection is established.When connection is established, server creates a new socket (Connection Socket) to communicate with that client and the Welcoming socket is once again waiting for connections for other clients.
  • 41. create socket,connect to hostid, port=xcreate socket,port=x, forincoming request:clientSocket = Socket()welcomeSocket = ServerSocket()wait for incomingconnection requestconnectionSocket =welcomeSocket.accept()send request usingclientSocketread request fromconnectionSocketwrite reply toconnectionSocketread reply fromconnectionSocketcloseconnectionSocketcloseclientSocketClient/Server Socket Interaction in TCPServerClientTCP connection setup
  • 42. Step 1 :Step 2 :ServerportServerConnection requestportClientportportClientConnection
  • 43. Types of Sockets in TCPServerSocket – the socket used by serversSocket – Socket used by clientsCreate a ServerSocket in the server and make it to wait for connections from Sockets from other clients
  • 44. The concept of StreamsClient output streamServer input streamServer socketClient socketClient input streamServer output stream
  • 45. Socket Programming with UDPNo Connection between client and server.No handshakingThe sender has to explicitly mention the IP address and the port of the destination.The server should extract the IP Address of the datagram everytime.Uses DatagramSocket.
  • 46. Clientcreate socket,port=x, forincoming request:serverSocket = DatagramSocket()create socket,clientSocket = DatagramSocket()Create, address (hostid, port=x),send datagram request using clientSocketread request fromserverSocketwrite reply toserverSocketspecifying clienthost address,port numberread reply fromclientSocketcloseclientSocketClient/server socket interaction: UDPServer
  • 48. ConclusionSocket Programming is very easy in Java.Usually each and every socket is handled by a separate thread in real-time client/server environments.