SlideShare a Scribd company logo
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,..)
Ad

More Related Content

What's hot (20)

Socket programming
Socket programmingSocket programming
Socket programming
harsh_bca06
 
Java socket programming
Java socket programmingJava socket programming
Java socket programming
Mohammed Abdalla Youssif
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
Vipin Yadav
 
Java Networking
Java NetworkingJava Networking
Java Networking
Sunil OS
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)
Peter R. Egli
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
Raja Sekhar
 
Java - Sockets
Java - SocketsJava - Sockets
Java - Sockets
Riccardo Cardin
 
Tcp/ip server sockets
Tcp/ip server socketsTcp/ip server sockets
Tcp/ip server sockets
rajshreemuthiah
 
Content provider in_android
Content provider in_androidContent provider in_android
Content provider in_android
PRITI TELMORE
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 
servlet in java
servlet in javaservlet in java
servlet in java
sowfi
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
Shraddha
 
Applets in java
Applets in javaApplets in java
Applets in java
Wani Zahoor
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
Jafar Nesargi
 
Socket programming using java
Socket programming using javaSocket programming using java
Socket programming using java
UC San Diego
 
Java RMI
Java RMIJava RMI
Java RMI
Prajakta Nimje
 
Application layer protocols
Application layer protocolsApplication layer protocols
Application layer protocols
JUW Jinnah University for Women
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
Vikas Jagtap
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
Sahil Agarwal
 
graphics programming in java
graphics programming in javagraphics programming in java
graphics programming in java
Abinaya B
 
Socket programming
Socket programmingSocket programming
Socket programming
harsh_bca06
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
Vipin Yadav
 
Java Networking
Java NetworkingJava Networking
Java Networking
Sunil OS
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)
Peter R. Egli
 
Content provider in_android
Content provider in_androidContent provider in_android
Content provider in_android
PRITI TELMORE
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 
servlet in java
servlet in javaservlet in java
servlet in java
sowfi
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
Shraddha
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
Jafar Nesargi
 
Socket programming using java
Socket programming using javaSocket programming using java
Socket programming using java
UC San Diego
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
Sahil Agarwal
 
graphics programming in java
graphics programming in javagraphics programming in java
graphics programming in java
Abinaya B
 

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

Sockets
SocketsSockets
Sockets
sivindia
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
Socket
SocketSocket
Socket
Amandeep Kaur
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
Nitish Nagar
 
Java Network Programming.pptx
Java Network Programming.pptxJava Network Programming.pptx
Java Network Programming.pptx
RoshniSundrani
 
Socket programming
Socket programmingSocket programming
Socket programming
Padmavathione
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat application
Samsil Arefin
 
Chat server nitish nagar
Chat server nitish nagarChat server nitish nagar
Chat server nitish nagar
Nitish Nagar
 
Md13 networking
Md13 networkingMd13 networking
Md13 networking
Rakesh Madugula
 
Java 1
Java 1Java 1
Java 1
VidyaVarshini3
 
Socket Programming by Rajkumar Buyya
Socket Programming by Rajkumar BuyyaSocket Programming by Rajkumar Buyya
Socket Programming by Rajkumar Buyya
iDhawalVaja
 
Client server project
Client server projectClient server project
Client server project
yogendra kumar patel
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
elliando dias
 
Os 2
Os 2Os 2
Os 2
university of Gujrat, pakistan
 
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYAPYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
Maulik Borsaniya
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
Mousmi Pawar
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in Java
Tushar B Kute
 
Mail Server Project Report
Mail Server Project ReportMail Server Project Report
Mail Server Project Report
Kavita Sharma
 
Socket programming
Socket programmingSocket programming
Socket programming
Anurag Tomar
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
Nitish Nagar
 
Java Network Programming.pptx
Java Network Programming.pptxJava Network Programming.pptx
Java Network Programming.pptx
RoshniSundrani
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat application
Samsil Arefin
 
Chat server nitish nagar
Chat server nitish nagarChat server nitish nagar
Chat server nitish nagar
Nitish Nagar
 
Socket Programming by Rajkumar Buyya
Socket Programming by Rajkumar BuyyaSocket Programming by Rajkumar Buyya
Socket Programming by Rajkumar Buyya
iDhawalVaja
 
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYAPYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
Maulik Borsaniya
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
Mousmi Pawar
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in Java
Tushar B Kute
 
Mail Server Project Report
Mail Server Project ReportMail Server Project Report
Mail Server Project Report
Kavita Sharma
 
Socket programming
Socket programmingSocket programming
Socket programming
Anurag Tomar
 
Ad

More from UC San Diego (19)

A primer on network devices
A primer on network devicesA primer on network devices
A primer on network devices
UC San Diego
 
Datacenter traffic demand characterization
Datacenter traffic demand characterizationDatacenter traffic demand characterization
Datacenter traffic demand characterization
UC San Diego
 
Smart Homes, Buildings and Internet-of-things
Smart Homes, Buildings and Internet-of-thingsSmart Homes, Buildings and Internet-of-things
Smart Homes, Buildings and Internet-of-things
UC San Diego
 
Social Networks analysis to characterize HIV at-risk populations - Progress a...
Social Networks analysis to characterize HIV at-risk populations - Progress a...Social Networks analysis to characterize HIV at-risk populations - Progress a...
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
eyeTalk - A system for helping people affected by motor neuron problemseyeTalk - A system for helping people affected by motor neuron problems
eyeTalk - A system for helping people affected by motor neuron problems
UC San Diego
 
Pirc net poster
Pirc net posterPirc net poster
Pirc net poster
UC San Diego
 
Ajaxism
AjaxismAjaxism
Ajaxism
UC San Diego
 
Basic terminologies for a developer
Basic terminologies for a developerBasic terminologies for a developer
Basic terminologies for a developer
UC San Diego
 
Fields in computer science
Fields in computer scienceFields in computer science
Fields in computer science
UC San Diego
 
Understanding computer networks
Understanding computer networksUnderstanding computer networks
Understanding computer networks
UC San Diego
 
FOSS Introduction
FOSS IntroductionFOSS Introduction
FOSS Introduction
UC San Diego
 
Network Programming with Umit project
Network Programming with Umit projectNetwork Programming with Umit project
Network Programming with Umit project
UC San Diego
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
UC San Diego
 
Airline reservation system db design
Airline reservation system db designAirline reservation system db design
Airline reservation system db design
UC San Diego
 
Workshop on Network Security
Workshop on Network SecurityWorkshop on Network Security
Workshop on Network Security
UC San Diego
 
Routing basics
Routing basicsRouting basics
Routing basics
UC San Diego
 
Technology Quiz
Technology QuizTechnology Quiz
Technology Quiz
UC San Diego
 
Android application development
Android application developmentAndroid application development
Android application development
UC San Diego
 
Pervasive Web Application Architecture
Pervasive Web Application ArchitecturePervasive Web Application Architecture
Pervasive Web Application Architecture
UC San Diego
 
A primer on network devices
A primer on network devicesA primer on network devices
A primer on network devices
UC San Diego
 
Datacenter traffic demand characterization
Datacenter traffic demand characterizationDatacenter traffic demand characterization
Datacenter traffic demand characterization
UC San Diego
 
Smart Homes, Buildings and Internet-of-things
Smart Homes, Buildings and Internet-of-thingsSmart Homes, Buildings and Internet-of-things
Smart Homes, Buildings and Internet-of-things
UC San Diego
 
Social Networks analysis to characterize HIV at-risk populations - Progress a...
Social Networks analysis to characterize HIV at-risk populations - Progress a...Social Networks analysis to characterize HIV at-risk populations - Progress a...
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
eyeTalk - A system for helping people affected by motor neuron problemseyeTalk - A system for helping people affected by motor neuron problems
eyeTalk - A system for helping people affected by motor neuron problems
UC San Diego
 
Basic terminologies for a developer
Basic terminologies for a developerBasic terminologies for a developer
Basic terminologies for a developer
UC San Diego
 
Fields in computer science
Fields in computer scienceFields in computer science
Fields in computer science
UC San Diego
 
Understanding computer networks
Understanding computer networksUnderstanding computer networks
Understanding computer networks
UC San Diego
 
Network Programming with Umit project
Network Programming with Umit projectNetwork Programming with Umit project
Network Programming with Umit project
UC San Diego
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
UC San Diego
 
Airline reservation system db design
Airline reservation system db designAirline reservation system db design
Airline reservation system db design
UC San Diego
 
Workshop on Network Security
Workshop on Network SecurityWorkshop on Network Security
Workshop on Network Security
UC San Diego
 
Android application development
Android application developmentAndroid application development
Android application development
UC San Diego
 
Pervasive Web Application Architecture
Pervasive Web Application ArchitecturePervasive Web Application Architecture
Pervasive Web Application Architecture
UC San Diego
 
Ad

Recently uploaded (20)

Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 

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.