CHAPTER 2 :
Internet Addressing & Data Stream
By :
Mr. Asyran Zarizi Bin Abdullah
Socket Programming
• Socket is a IPC (Inter Process Communication)
facility for network application.
• To make socket communicate with other
socket, so it need unique address as a
identifier.
• Socket Address contain IP Address and Port
Number. Example : 192.168.20.12 : 8080
IP Address Port Number
What is IP ?
W2-1-2, Kuates Staff
Politeknik Muadzam Shah,
26700, Pahang D.M
W2-1-2, Kuates Staff
Politeknik Muadzam
Shah,
26700, Pahang D.M
PC A
(Source)
PC B
(Destination)
172.168.2.3 10.10.10.34
An Analogy
HERE WE KNOW THE IMPORTANT IS…
Internet Addressing
• IP is stand for Internet Protocol.
• IP is an unique ID.
• It use for communicate between 1 point to
another point in network.
• Public & Private
• IPv4 has 32 bits , example : 192.168.32.12
but IP Address is running out….
Quiz :
What is the solution for
ipv4 issues?
Quiz :
What is the solution for
ipv4 issues?
Answer : ipv6
What is this??
This is IPV4 
4,294,672,96
340,282,366,920,938,463,463,
374,607,431,768,211,456
340 Undecillion!!!
Internet Addressing in JAVA
• Java is a capable programming language that is
capable to support networked environment
which support most popular protocol available
• Java API that support internet addressing is :-
– InetAddress
• There are two subclasses under it
– Inet4Address
– Inet6Address
– An InetAddress object is capable to store IP address or
Domain name which later used for communication
address or translation between the form available.
IP Addresses & Hostname
• Java.net.InetAddress class
– Represents a single IP Address
– Performs transparent DNS lookups
• Java.net.UnknownHostException class
– Thrown if DNS system can`t find IP address for
specific host
InetAddress class
• Creating an InetAddress object is as follow:-
• Some of the useful methods within InetAddress class
– getHostName()
• It return the host domain name in String format
– getHostAddress()
• It return the IP address in String format
– getLocalHost()
• It return InetAddress object with local computer address information
with its host name
– getByName()
• It return InetAddress object of a destination computer containing its
address and host name
getByName example
getHostName example
getHostAddress example
getLocalHost example
Socket & Protocol

Chapter 2 : Inet Address & Data Stream

  • 1.
    CHAPTER 2 : InternetAddressing & Data Stream By : Mr. Asyran Zarizi Bin Abdullah
  • 2.
    Socket Programming • Socketis a IPC (Inter Process Communication) facility for network application. • To make socket communicate with other socket, so it need unique address as a identifier. • Socket Address contain IP Address and Port Number. Example : 192.168.20.12 : 8080 IP Address Port Number
  • 3.
  • 4.
    W2-1-2, Kuates Staff PoliteknikMuadzam Shah, 26700, Pahang D.M W2-1-2, Kuates Staff Politeknik Muadzam Shah, 26700, Pahang D.M PC A (Source) PC B (Destination) 172.168.2.3 10.10.10.34 An Analogy
  • 5.
    HERE WE KNOWTHE IMPORTANT IS…
  • 6.
    Internet Addressing • IPis stand for Internet Protocol. • IP is an unique ID. • It use for communicate between 1 point to another point in network. • Public & Private • IPv4 has 32 bits , example : 192.168.32.12 but IP Address is running out….
  • 7.
    Quiz : What isthe solution for ipv4 issues?
  • 8.
    Quiz : What isthe solution for ipv4 issues? Answer : ipv6
  • 10.
  • 11.
  • 12.
  • 14.
  • 15.
  • 22.
    Internet Addressing inJAVA • Java is a capable programming language that is capable to support networked environment which support most popular protocol available • Java API that support internet addressing is :- – InetAddress • There are two subclasses under it – Inet4Address – Inet6Address – An InetAddress object is capable to store IP address or Domain name which later used for communication address or translation between the form available.
  • 23.
    IP Addresses &Hostname • Java.net.InetAddress class – Represents a single IP Address – Performs transparent DNS lookups • Java.net.UnknownHostException class – Thrown if DNS system can`t find IP address for specific host
  • 24.
    InetAddress class • Creatingan InetAddress object is as follow:- • Some of the useful methods within InetAddress class – getHostName() • It return the host domain name in String format – getHostAddress() • It return the IP address in String format – getLocalHost() • It return InetAddress object with local computer address information with its host name – getByName() • It return InetAddress object of a destination computer containing its address and host name
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.