SlideShare a Scribd company logo
Group Members
Gurpreet Kaur(155)
  Himani Kakria
  Ritika Sharma
   Reetu Rani
Contents
O Socket Programming
O Server-Client Communication
O .net Package
O The InetAddress Class & its methods
      O getLocalHost()
      O getByName(String hostName)
      O getAllByName(String hostName)
      O getAddress() & getHostName()
O Socket Class
O ServerSocketClass
Socket Programming
Networking - process of making two or more computers
communicate.

The important concept associated with networking is the concept of
Sockets and Ports.

SOCKET - A socket is one end-point of a two-way communication link
between two programs running on the network.

Socket classes are used to represent the connection between a client
program and a server program.
Server-Client Communication
O Normally, a server has a socket that is bound to a specific port
    number.
O   On the client-side: The client knows the hostname of the machine
    on which the server is running and the port number on which the
    server is listening.
O   To make a connection request, the client tries to connect with the
    server on the server's machine and port.
O   If everything goes well, the server accepts the connection.
O   On the client side, if the connection is accepted, a socket is
    successfully created and the client can use the socket to
    communicate with the server.
.net Package
O Provide support for networking.


O Contains classes and interfaces to encapsulate the “Socket”
  Paradigm.

O The java.net package provides two classes—
     O Socket - implement the client side of the connection
     O Ser verSocket- implement the server side of the connection
The InetAddress Class
O It converts the domain name of Internet address into an
  Object. This class represents an Internet Protocol (IP)
  address.

O Doesn’t have Constructors.


O Three static methods are used to create instances.
      O getLocalHost()
      O getByName(String hostName)
      O getAllByName(String hostName)


O All these methods throw UnknownHostException if the
  method cannot resolve the host name.
getLocalHost()
import java.net.*;
class obtainIP
{
          public static void main(String args []) throws UnknownHostException
          {
                    InetAddress adr;
                    adr=InetAddress.getLocalHost();
                    System.out.println("nInfo about Machine: " + adr);
          }
}
getByName(String hostName)
import java.io.*;
import java.net.*;
class obtainIP2
{           public static void main(String args []) throws IOException
            {           InetAddress adr;
                        String host;
                        DataInputStream input=new DataInputStream(System.in);
                        System.out.println("Enter the Machine's Hostname");
                        host=input.readLine();
            try {
                        adr=InetAddress.getByName(host);
                        System.out.println("nInfo about Host "" + host + "" is:- " + adr);
                }
            catch( UnknownHostException e) {
                        System.out.println("No such host exist"); }
            }
}
Output
getAllByName(String hostName)

import java.io.*;                          try {
import java.net.*;                              adr=InetAddress.getAllByName(host);
class obtainIP3                                 for(int i=0;i<adr.length;i++)
{                                               {
public static void main(String args [ ])            j++;
throws IOException                                  System.out.println(j +"t" + adr[i]);
 {                                               }
     InetAddress adr[]; int j=0;                }
     String host;
     DataInputStream input=new             catch( UnknownHostException e)
DataInputStream(System.in);                    {
                                             System.out.println("No such host exist");
     System.out.println("Enter host ");        }
     host=input.readLine();                }
                                           }
Output
getAddress() & getHostName()
import java.net.*;
class obtainIP4
{           public static void main(String args []) throws UnknownHostException
            {
                        String msg;
                        byte num[];
                        InetAddress adr;
                        adr=InetAddress.getLocalHost();
                        num=adr.getAddress();
                        msg=adr.getHostName();
                        System.out.println("LocalHost= " + adr);
                        for(int i=0;i<num.length;i++)
                        {
                                     msg +=(num[i] & 255) + ".";
                                     System.out.println("Num= " + msg);
                        }
            }
}
Output
Socket Class
O The Socket class ,basically used to create client sockets, is
  designed to connect to server socket and initiate protocol
  exchanges.

O When Socket object is created, it implicitly establishes the
  connection b/w client and server.

O Socket defines the constructors to create client sockets.


Constructors:-
  Socket(String hostname, int port);
  Socket(InetAdrress ipaddr, int port);
Socket Class Methods
Methods:-

1)InputStream getInputStream();


1)OutputStream getOutputStream();


1)void close();
ServerSocket Class
The ServerSocket class, basically used to create server sockets,
is designed to be a listener, which waits for client to connect
before doing anything.

Constructors:-
       ServerSocket ( int port );
       ServerSocket ( int port, int queueLength);
Method:-
       Socket accept();

accept() is a blocking call that waits for a client to initiate
communication and returns a normal Socket, that is used for
communication with the client.
Ppt of socket

More Related Content

What's hot

Socket programming in Java (PPTX)
Socket programming in Java (PPTX)Socket programming in Java (PPTX)
Socket programming in Java (PPTX)UC San Diego
 
Socket programming
Socket programmingSocket programming
Socket programming
Ujjwal Kumar
 
UDP - User Datagram Protocol
UDP - User Datagram ProtocolUDP - User Datagram Protocol
UDP - User Datagram Protocol
Peter R. Egli
 
Routing
RoutingRouting
Routing
Saima Azam
 
IPV6 ADDRESS
IPV6 ADDRESSIPV6 ADDRESS
IPV6 ADDRESS
Jothi Lakshmi
 
Chap2. ipv4-arp-icmp
Chap2. ipv4-arp-icmpChap2. ipv4-arp-icmp
Chap2. ipv4-arp-icmp
東原 李
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
Vipin Yadav
 
Transport layer
Transport layer Transport layer
Transport layer
Mukesh Chinta
 
Presentation on arp protocol
Presentation on arp protocolPresentation on arp protocol
Presentation on arp protocol
Mohd. Ahmad Siddiqi
 
Link state routing protocol
Link state routing protocolLink state routing protocol
Link state routing protocol
Aung Thu Rha Hein
 
ICMP
ICMPICMP
Transport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And DemultiplexingTransport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And Demultiplexing
Keyur Vadodariya
 
Java Networking
Java NetworkingJava Networking
Java Networking
Sunil OS
 
Runnable interface.34
Runnable interface.34Runnable interface.34
Runnable interface.34myrajendra
 
IPv6 header
IPv6 headerIPv6 header
IPv6 header
Heba_a
 
Socket Programming Tutorial
Socket Programming TutorialSocket Programming Tutorial
Socket Programming Tutorial
Jignesh Patel
 

What's hot (20)

Socket programming in Java (PPTX)
Socket programming in Java (PPTX)Socket programming in Java (PPTX)
Socket programming in Java (PPTX)
 
Icmp
IcmpIcmp
Icmp
 
Socket programming
Socket programmingSocket programming
Socket programming
 
UDP - User Datagram Protocol
UDP - User Datagram ProtocolUDP - User Datagram Protocol
UDP - User Datagram Protocol
 
Routing
RoutingRouting
Routing
 
IPV6 ADDRESS
IPV6 ADDRESSIPV6 ADDRESS
IPV6 ADDRESS
 
Chap2. ipv4-arp-icmp
Chap2. ipv4-arp-icmpChap2. ipv4-arp-icmp
Chap2. ipv4-arp-icmp
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
 
Transport layer
Transport layer Transport layer
Transport layer
 
Sockets
SocketsSockets
Sockets
 
Presentation on arp protocol
Presentation on arp protocolPresentation on arp protocol
Presentation on arp protocol
 
Link state routing protocol
Link state routing protocolLink state routing protocol
Link state routing protocol
 
Ipv4 and Ipv6
Ipv4 and Ipv6Ipv4 and Ipv6
Ipv4 and Ipv6
 
ICMP
ICMPICMP
ICMP
 
Transport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And DemultiplexingTransport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And Demultiplexing
 
Java Networking
Java NetworkingJava Networking
Java Networking
 
Runnable interface.34
Runnable interface.34Runnable interface.34
Runnable interface.34
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
IPv6 header
IPv6 headerIPv6 header
IPv6 header
 
Socket Programming Tutorial
Socket Programming TutorialSocket Programming Tutorial
Socket Programming Tutorial
 

Similar to Ppt of socket

Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
Sivadon Chaisiri
 
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Mumbai B.Sc.IT Study
 
nw-lab_dns-server.pdf
nw-lab_dns-server.pdfnw-lab_dns-server.pdf
nw-lab_dns-server.pdf
Jayaprasanna4
 
Pemrograman Jaringan
Pemrograman JaringanPemrograman Jaringan
Pemrograman Jaringan
belajarkomputer
 
Laporan multiclient chatting client server
Laporan multiclient chatting client serverLaporan multiclient chatting client server
Laporan multiclient chatting client servertrilestari08
 
Lab manual cn-2012-13
Lab manual cn-2012-13Lab manual cn-2012-13
Lab manual cn-2012-13Sasi Kala
 
CHAPTER - 3 - JAVA NETWORKING.pptx
CHAPTER - 3 - JAVA NETWORKING.pptxCHAPTER - 3 - JAVA NETWORKING.pptx
CHAPTER - 3 - JAVA NETWORKING.pptx
DhrumilSheth3
 
Advance Java-Network Programming
Advance Java-Network ProgrammingAdvance Java-Network Programming
Advance Java-Network Programming
ashok hirpara
 
JavaExamples
JavaExamplesJavaExamples
JavaExamples
Suman Astani
 
Laporan multi client
Laporan multi clientLaporan multi client
Laporan multi clientichsanbarokah
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programmingAnung Ariwibowo
 
Distributed systems
Distributed systemsDistributed systems
Distributed systems
Sonali Parab
 
Network programming in java - PPT
Network programming in java - PPTNetwork programming in java - PPT
Network programming in java - PPT
kamal kotecha
 
Chatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopChatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopyayaria
 
DCN Practical
DCN PracticalDCN Practical
DCN Practical
Niraj Bharambe
 
Java networking
Java networkingJava networking
Java networking
ssuser3a47cb
 

Similar to Ppt of socket (20)

java sockets
 java sockets java sockets
java sockets
 
Lecture6
Lecture6Lecture6
Lecture6
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
 
nw-lab_dns-server.pdf
nw-lab_dns-server.pdfnw-lab_dns-server.pdf
nw-lab_dns-server.pdf
 
Pemrograman Jaringan
Pemrograman JaringanPemrograman Jaringan
Pemrograman Jaringan
 
Laporan multiclient chatting client server
Laporan multiclient chatting client serverLaporan multiclient chatting client server
Laporan multiclient chatting client server
 
Lab manual cn-2012-13
Lab manual cn-2012-13Lab manual cn-2012-13
Lab manual cn-2012-13
 
CHAPTER - 3 - JAVA NETWORKING.pptx
CHAPTER - 3 - JAVA NETWORKING.pptxCHAPTER - 3 - JAVA NETWORKING.pptx
CHAPTER - 3 - JAVA NETWORKING.pptx
 
Network
NetworkNetwork
Network
 
Advance Java-Network Programming
Advance Java-Network ProgrammingAdvance Java-Network Programming
Advance Java-Network Programming
 
JavaExamples
JavaExamplesJavaExamples
JavaExamples
 
Laporan multi client
Laporan multi clientLaporan multi client
Laporan multi client
 
分散式系統
分散式系統分散式系統
分散式系統
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programming
 
Distributed systems
Distributed systemsDistributed systems
Distributed systems
 
Network programming in java - PPT
Network programming in java - PPTNetwork programming in java - PPT
Network programming in java - PPT
 
Chatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopChatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptop
 
DCN Practical
DCN PracticalDCN Practical
DCN Practical
 
Java networking
Java networkingJava networking
Java networking
 

More from Amandeep Kaur

Video/ Graphics cards
Video/ Graphics  cardsVideo/ Graphics  cards
Video/ Graphics cardsAmandeep Kaur
 
Menu pop up menu mdi form and playing audio in vb
Menu pop up menu mdi form and playing audio in vbMenu pop up menu mdi form and playing audio in vb
Menu pop up menu mdi form and playing audio in vbAmandeep Kaur
 
Image contro, and format functions in vb
Image contro, and format functions in vbImage contro, and format functions in vb
Image contro, and format functions in vbAmandeep Kaur
 
Data base connectivity and flex grid in vb
Data base connectivity and flex grid in vbData base connectivity and flex grid in vb
Data base connectivity and flex grid in vbAmandeep Kaur
 
Toolbar, statusbar, coolbar in vb
Toolbar, statusbar, coolbar in vbToolbar, statusbar, coolbar in vb
Toolbar, statusbar, coolbar in vbAmandeep Kaur
 
Socket
SocketSocket
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphicsAmandeep Kaur
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphicsAmandeep Kaur
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphicsAmandeep Kaur
 
Report on browser war
Report on browser warReport on browser war
Report on browser warAmandeep Kaur
 
Report of internet connections
Report of internet connectionsReport of internet connections
Report of internet connectionsAmandeep Kaur
 

More from Amandeep Kaur (20)

Video/ Graphics cards
Video/ Graphics  cardsVideo/ Graphics  cards
Video/ Graphics cards
 
Menu vb
Menu vbMenu vb
Menu vb
 
Menu pop up menu mdi form and playing audio in vb
Menu pop up menu mdi form and playing audio in vbMenu pop up menu mdi form and playing audio in vb
Menu pop up menu mdi form and playing audio in vb
 
Active x control
Active x controlActive x control
Active x control
 
Image contro, and format functions in vb
Image contro, and format functions in vbImage contro, and format functions in vb
Image contro, and format functions in vb
 
Data base connectivity and flex grid in vb
Data base connectivity and flex grid in vbData base connectivity and flex grid in vb
Data base connectivity and flex grid in vb
 
Toolbar, statusbar, coolbar in vb
Toolbar, statusbar, coolbar in vbToolbar, statusbar, coolbar in vb
Toolbar, statusbar, coolbar in vb
 
Richtextbox
RichtextboxRichtextbox
Richtextbox
 
Treeview listview
Treeview listviewTreeview listview
Treeview listview
 
Progress bar
Progress barProgress bar
Progress bar
 
Filehandling
FilehandlingFilehandling
Filehandling
 
Socket
SocketSocket
Socket
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
 
Internet
InternetInternet
Internet
 
Internet working
Internet workingInternet working
Internet working
 
Report on browser war
Report on browser warReport on browser war
Report on browser war
 
Report of internet connections
Report of internet connectionsReport of internet connections
Report of internet connections
 
Report on intranet
Report on intranetReport on intranet
Report on intranet
 

Recently uploaded

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 

Recently uploaded (20)

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 

Ppt of socket

  • 1. Group Members Gurpreet Kaur(155) Himani Kakria Ritika Sharma Reetu Rani
  • 2. Contents O Socket Programming O Server-Client Communication O .net Package O The InetAddress Class & its methods O getLocalHost() O getByName(String hostName) O getAllByName(String hostName) O getAddress() & getHostName() O Socket Class O ServerSocketClass
  • 3. Socket Programming Networking - process of making two or more computers communicate. The important concept associated with networking is the concept of Sockets and Ports. SOCKET - A socket is one end-point of a two-way communication link between two programs running on the network. Socket classes are used to represent the connection between a client program and a server program.
  • 4. Server-Client Communication O Normally, a server has a socket that is bound to a specific port number. O On the client-side: The client knows the hostname of the machine on which the server is running and the port number on which the server is listening. O To make a connection request, the client tries to connect with the server on the server's machine and port. O If everything goes well, the server accepts the connection. O On the client side, if the connection is accepted, a socket is successfully created and the client can use the socket to communicate with the server.
  • 5. .net Package O Provide support for networking. O Contains classes and interfaces to encapsulate the “Socket” Paradigm. O The java.net package provides two classes— O Socket - implement the client side of the connection O Ser verSocket- implement the server side of the connection
  • 6. The InetAddress Class O It converts the domain name of Internet address into an Object. This class represents an Internet Protocol (IP) address. O Doesn’t have Constructors. O Three static methods are used to create instances. O getLocalHost() O getByName(String hostName) O getAllByName(String hostName) O All these methods throw UnknownHostException if the method cannot resolve the host name.
  • 7. getLocalHost() import java.net.*; class obtainIP { public static void main(String args []) throws UnknownHostException { InetAddress adr; adr=InetAddress.getLocalHost(); System.out.println("nInfo about Machine: " + adr); } }
  • 8. getByName(String hostName) import java.io.*; import java.net.*; class obtainIP2 { public static void main(String args []) throws IOException { InetAddress adr; String host; DataInputStream input=new DataInputStream(System.in); System.out.println("Enter the Machine's Hostname"); host=input.readLine(); try { adr=InetAddress.getByName(host); System.out.println("nInfo about Host "" + host + "" is:- " + adr); } catch( UnknownHostException e) { System.out.println("No such host exist"); } } }
  • 10. getAllByName(String hostName) import java.io.*; try { import java.net.*; adr=InetAddress.getAllByName(host); class obtainIP3 for(int i=0;i<adr.length;i++) { { public static void main(String args [ ]) j++; throws IOException System.out.println(j +"t" + adr[i]); { } InetAddress adr[]; int j=0; } String host; DataInputStream input=new catch( UnknownHostException e) DataInputStream(System.in); { System.out.println("No such host exist"); System.out.println("Enter host "); } host=input.readLine(); } }
  • 12. getAddress() & getHostName() import java.net.*; class obtainIP4 { public static void main(String args []) throws UnknownHostException { String msg; byte num[]; InetAddress adr; adr=InetAddress.getLocalHost(); num=adr.getAddress(); msg=adr.getHostName(); System.out.println("LocalHost= " + adr); for(int i=0;i<num.length;i++) { msg +=(num[i] & 255) + "."; System.out.println("Num= " + msg); } } }
  • 14. Socket Class O The Socket class ,basically used to create client sockets, is designed to connect to server socket and initiate protocol exchanges. O When Socket object is created, it implicitly establishes the connection b/w client and server. O Socket defines the constructors to create client sockets. Constructors:- Socket(String hostname, int port); Socket(InetAdrress ipaddr, int port);
  • 15. Socket Class Methods Methods:- 1)InputStream getInputStream(); 1)OutputStream getOutputStream(); 1)void close();
  • 16. ServerSocket Class The ServerSocket class, basically used to create server sockets, is designed to be a listener, which waits for client to connect before doing anything. Constructors:- ServerSocket ( int port ); ServerSocket ( int port, int queueLength); Method:- Socket accept(); accept() is a blocking call that waits for a client to initiate communication and returns a normal Socket, that is used for communication with the client.