Documente Academic
Documente Profesional
Documente Cultură
Programmi
ng
TOPICS
Basic Concepts, Protocols and Terminology,
Internet Services,
Ports and
Sockets
Ports and
Sockets
Abstract concepts of hardware ports and sockets
that allow the programmer to make use of those
communication links.
What is a port ?
a logical connection to a computer
identified by a number in the range 1-65535
No relations with physical connections to the
computer
Ports range 1-1023 are reserved (well known
ports)
Ports and
Sockets
What are sockets?
It is used to indicate one of the two end-points of
a communication link between two processes.
Client it will initially create a socket at its end of
the communication link.
Internet Services,
URLs and DNS
What is a
protocol?
Rules governing the communication that
takes place between server and client.
Structure of a URL :
from
the
directory
specified
in
the
path
name
(index.html)
2. The 'section' part of the URL indicates a named 'anchor' in
an
HTML
document
example
<A
java.sun.com
The individual parts of a domain name don't
correspond to the individual parts of an IP
address
The
IP
address
system
and
the
DNS
are
Transmission
Control
Protocol
So, it was
User Datagram
Protocol
Why
TCP
is robust , BUT
UDP?
Overhead of providing facilities such as
confirmation of receipt
Why
UDP?
UDP
is an unreliable protocol
1. It doesn't guarantee that each packet will
arrive;
2. It doesn't guarantee that packets will be
in the right order.
3. UDP doesn't re-send a packet if it is
missing or there is some other error, and
4.
Starting
Network
Programmin
g
Core package : java.net
The InetAddress
Class
The InetAddress
Handles Internet addresses both as host
Class
names and as IP addresses
Method :
getByName() (Static) :
the
checked
UnknownHostException
name is not recognised
exception
if
the
host
Using
Sockets
(TCP/IP)
OutputStream
getOutputStream.
object
returned
by
method
Example
Datagram (UDP)
Sockets
Instead,
Server setup
Server setup
Methods
getAddress
and
getPort
of
our
Server setup
Server setup
Create a DatagramPacket object, using an
overloaded form of the constructor that takes
four arguments:
Server setup