JAVA NETWORKING
A Data gram is an independent, self-contained message sent over the network whose
arrival, arrival time and content are guaranteed.
It is a basic transfer unit associated with a packet-switched network.
Data gram Socket, Data gram Packet and Multicast Socket.
An application can send and receive Data gram Packets through a Datagram Socket.
METHOD
|
DESCRIPTION
|
inetAddress
getByName
()
|
This method returns the IP address
when the hostname is given.
|
inetAddress getAddress
()
|
This method returns the IP address.
|
Int getPort()
|
It returns the port number.
|
Byte[]getData()
|
It returns the data containing in
the datagram. this is stored in the array of bytes.
|
Int getLength()
|
Returns the length of data obtained
by get data method.
|
Data gram Packets can be broadcast to multiple recipients all listening to a Multicast Socket.
Data gram Socket:
Data gram Socket
class represents a connection-less socket for sending and receiving data gram packets.
A datagram is basically an information but there
is no guarantee of its
content, arrival or arrival time.
Constructor:
Data gram Packet:
DatagramSocket()
|
It creates a datagram socket
and binds it with the
available Port Number on the local host machine.
|
DatagramSocket
(int port) |
It creates a datagram socket
and binds it
with the given
Port Number.
|
DatagramSocket(int port, InetAddress
address)
|
It creates a datagram socket
and binds it with the
specified port number and
host address.
|
Data gram Packet:
Java Data gram Packet is a message
that can be sent or received.
Additionally, packet delivery
is not guaranteed.
Data gram packets are used to implement a connection less packet
delivery service.
Each message
is routed from one machine
to another based
solely on information contained within that
packet.
Multiple packets sent from
one machine to another might
be routed differently, and might arrive
in any order.
Constructor:
Data gram Packet
(byte[]
barr, int length)
|
It creates a data gram packet. This constructor is
used to receive the packets.
|
Data gram Packet
(byte[] barr,
int length, InetAddress
address, int port)
|
It creates a data gram packet. This constructor is
used to send the packets.
|
Post a Comment