SlideShare a Scribd company logo
1 of 23
Socket programming in java NarendranThangarajan, @naren_live, II Year, BE, CSE, SSN College of Engg, Chennai.
What started it all.. Internet  has emerged as a global ubiquitous media for communication It 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 Applications The Web Service is provided by the server  and the clients use these services Client Request Server Network Result Client machine Server machine A client, A server, and network This is where sockets come in !!
Sockets Introduced 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? ,[object Object]
    Port Number can be anything from 0 to 65,535.,[object Object]
IP Address -> MAC Address – Locate the 						specific system Destination Socket = 10.0.0.2 : 80 10.0.0.1 10.0.0.2
Port Number – Process specific Port 10000 Port 11000 Port 120000
Understanding Ports Gmail YM AVG  Update OutLook Express Port 1 Port 2 Port 3 Port 4 Transport Layer Packet Port num data Network layer
Thus virtually, sockets are a connection between the two processes in different systems. Eg : Let the socket pairs be 10.0.0.1 : 80 and 20.0.0.1 : 2000 192.168.21.10 : 3000 and 192.168.100.1 : 6000
Networking Basics – the larger picture ,[object Object]
Standard apps
HTTP
FTP
Telnet
User apps
Transport Layer
TCP
UDP
Network Layer
IP
Link Layer
Device driversTCP STACK Application (http,ftp,telnet,…) Transport (TCP, UDP,..) Network (IP,..) Link (device driver,..)

More Related Content

What's hot (20)

Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Java Streams
Java StreamsJava Streams
Java Streams
 
Tcp/ip server sockets
Tcp/ip server socketsTcp/ip server sockets
Tcp/ip server sockets
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
Applets in java
Applets in javaApplets in java
Applets in java
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Enumeration in Java Explained | Java Tutorial | Edureka
Enumeration in Java Explained | Java Tutorial | EdurekaEnumeration in Java Explained | Java Tutorial | Edureka
Enumeration in Java Explained | Java Tutorial | Edureka
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Java threads
Java threadsJava threads
Java threads
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Applets
AppletsApplets
Applets
 
Java Notes
Java Notes Java Notes
Java Notes
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
 
Graphics and Java 2D
Graphics and Java 2DGraphics and Java 2D
Graphics and Java 2D
 
Interface in java
Interface in javaInterface in java
Interface in java
 

Similar to Socket programming in Java (PPTX)

Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in JavaTushar B Kute
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagarNitish Nagar
 
Java Network Programming.pptx
Java Network Programming.pptxJava Network Programming.pptx
Java Network Programming.pptxRoshniSundrani
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat applicationSamsil Arefin
 
Chat server nitish nagar
Chat server nitish nagarChat server nitish nagar
Chat server nitish nagarNitish Nagar
 
Socket Programming by Rajkumar Buyya
Socket Programming by Rajkumar BuyyaSocket Programming by Rajkumar Buyya
Socket Programming by Rajkumar BuyyaiDhawalVaja
 
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYAPYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYAMaulik Borsaniya
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket ProgrammingMousmi Pawar
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in JavaTushar B Kute
 
Mail Server Project Report
Mail Server Project ReportMail Server Project Report
Mail Server Project ReportKavita Sharma
 
Socket programming
Socket programmingSocket programming
Socket programmingAnurag Tomar
 
Remote Procedure Call
Remote Procedure CallRemote Procedure Call
Remote Procedure CallNadia Nahar
 

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

Sockets
SocketsSockets
Sockets
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Socket
SocketSocket
Socket
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
 
Java Network Programming.pptx
Java Network Programming.pptxJava Network Programming.pptx
Java Network Programming.pptx
 
Socket programming
Socket programmingSocket programming
Socket programming
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat application
 
Chat server nitish nagar
Chat server nitish nagarChat server nitish nagar
Chat server nitish nagar
 
Md13 networking
Md13 networkingMd13 networking
Md13 networking
 
Java 1
Java 1Java 1
Java 1
 
Socket Programming by Rajkumar Buyya
Socket Programming by Rajkumar BuyyaSocket Programming by Rajkumar Buyya
Socket Programming by Rajkumar Buyya
 
Client server project
Client server projectClient server project
Client server project
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Os 2
Os 2Os 2
Os 2
 
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYAPYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in Java
 
Mail Server Project Report
Mail Server Project ReportMail Server Project Report
Mail Server Project Report
 
Socket programming
Socket programmingSocket programming
Socket programming
 
Remote Procedure Call
Remote Procedure CallRemote Procedure Call
Remote Procedure Call
 

More from UC San Diego

A primer on network devices
A primer on network devicesA primer on network devices
A primer on network devicesUC San Diego
 
Datacenter traffic demand characterization
Datacenter traffic demand characterizationDatacenter traffic demand characterization
Datacenter traffic demand characterizationUC 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-thingsUC 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 problemsUC San Diego
 
Basic terminologies for a developer
Basic terminologies for a developerBasic terminologies for a developer
Basic terminologies for a developerUC San Diego
 
Fields in computer science
Fields in computer scienceFields in computer science
Fields in computer scienceUC San Diego
 
Understanding computer networks
Understanding computer networksUnderstanding computer networks
Understanding computer networksUC San Diego
 
Network Programming with Umit project
Network Programming with Umit projectNetwork Programming with Umit project
Network Programming with Umit projectUC San Diego
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonUC San Diego
 
Airline reservation system db design
Airline reservation system db designAirline reservation system db design
Airline reservation system db designUC San Diego
 
Workshop on Network Security
Workshop on Network SecurityWorkshop on Network Security
Workshop on Network SecurityUC San Diego
 
Android application development
Android application developmentAndroid application development
Android application developmentUC San Diego
 
Pervasive Web Application Architecture
Pervasive Web Application ArchitecturePervasive Web Application Architecture
Pervasive Web Application ArchitectureUC San Diego
 

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
 
Datacenter traffic demand characterization
Datacenter traffic demand characterizationDatacenter traffic demand characterization
Datacenter traffic demand characterization
 
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
 
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...
 
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
 
Pirc net poster
Pirc net posterPirc net poster
Pirc net poster
 
Ajaxism
AjaxismAjaxism
Ajaxism
 
Basic terminologies for a developer
Basic terminologies for a developerBasic terminologies for a developer
Basic terminologies for a developer
 
Fields in computer science
Fields in computer scienceFields in computer science
Fields in computer science
 
Understanding computer networks
Understanding computer networksUnderstanding computer networks
Understanding computer networks
 
FOSS Introduction
FOSS IntroductionFOSS Introduction
FOSS Introduction
 
Network Programming with Umit project
Network Programming with Umit projectNetwork Programming with Umit project
Network Programming with Umit project
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Airline reservation system db design
Airline reservation system db designAirline reservation system db design
Airline reservation system db design
 
Workshop on Network Security
Workshop on Network SecurityWorkshop on Network Security
Workshop on Network Security
 
Routing basics
Routing basicsRouting basics
Routing basics
 
Technology Quiz
Technology QuizTechnology Quiz
Technology Quiz
 
Android application development
Android application developmentAndroid application development
Android application development
 
Pervasive Web Application Architecture
Pervasive Web Application ArchitecturePervasive Web Application Architecture
Pervasive Web Application Architecture
 

Recently uploaded

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 

Recently uploaded (20)

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 

Socket programming in Java (PPTX)

  • 1. Socket programming in java NarendranThangarajan, @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 communication It 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 Applications The Web Service is provided by the server and the clients use these services Client Request Server Network Result Client machine Server machine A client, A server, and network This is where sockets come in !!
  • 4. Sockets Introduced 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.
  • 6.
  • 7. IP Address -> MAC Address – Locate the specific system Destination Socket = 10.0.0.2 : 80 10.0.0.1 10.0.0.2
  • 8. Port Number – Process specific Port 10000 Port 11000 Port 120000
  • 9. Understanding Ports Gmail YM AVG Update OutLook Express Port 1 Port 2 Port 3 Port 4 Transport Layer Packet Port num data Network layer
  • 10. Thus virtually, sockets are a connection between the two processes in different systems. Eg : Let the socket pairs be 10.0.0.1 : 80 and 20.0.0.1 : 2000 192.168.21.10 : 3000 and 192.168.100.1 : 6000
  • 11.
  • 13. HTTP
  • 14. FTP
  • 18. TCP
  • 19. UDP
  • 21. IP
  • 23. Device driversTCP STACK Application (http,ftp,telnet,…) Transport (TCP, UDP,..) Network (IP,..) Link (device driver,..)
  • 24.
  • 26. HTTP
  • 27. FTP
  • 33. TCP
  • 34. UDP
  • 36. IP
  • 38. Device driversTCP STACK Application (http,ftp,telnet,…) Sockets Transport (TCP, UDP,..) Network (IP,..) Link (device driver,..)
  • 39. Now into Socket programming..
  • 40. Socket Programming with TCP Server starts first.. Server Process must be running first Server must have created a socket which welcomes client’s connection. (Welcoming socket) Client contacts server by.. Creating Client local TCP socket Specify 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=x create socket, port=x, for incoming request: clientSocket = Socket() welcomeSocket = ServerSocket() wait for incoming connection request connectionSocket = welcomeSocket.accept() send request using clientSocket read request from connectionSocket write reply to connectionSocket read reply from connectionSocket close connectionSocket close clientSocket Client/Server Socket Interaction in TCP Server Client TCP connection setup
  • 42. Step 1 : Step 2 : Server port Server Connection request port Client port port Client Connection
  • 43. Types of Sockets in TCP ServerSocket – the socket used by servers Socket – Socket used by clients Create a ServerSocket in the server and make it to wait for connections from Sockets from other clients
  • 44. The concept of Streams Client output stream Server input stream Server socket Client socket Client input stream Server output stream
  • 45. Socket Programming with UDP No Connection between client and server. No handshaking The 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. Client create socket, port=x, for incoming request: serverSocket = DatagramSocket() create socket, clientSocket = DatagramSocket() Create, address (hostid, port=x), send datagram request using clientSocket read request from serverSocket write reply to serverSocket specifying client host address, port number read reply from clientSocket close clientSocket Client/server socket interaction: UDP Server
  • 48. Conclusion Socket Programming is very easy in Java. Usually each and every socket is handled by a separate thread in real-time client/server environments.