Datagrams

rajshreemuthiah 702 views 9 slides Jan 20, 2020
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

datagrams


Slide Content

DATAGRAMS By C.Rajeswari, M.Sc( info.tech ), Nadar S araswathi College of Arts and Science, Theni.

Contents Introduction Datagram Socket Datagram Packet Example

INTRODUCTION TCP/IP-style networking is appropriate or most networking needs. It provides a serialized, predictable, reliable stream o packet data. Datagrams are bundles of information passed between machines. Java implements datagrams on top of the UDP protocol by using two classes: DatagramPacket (data container) DatagramSocket (mechanism used)

DatagramSocket The datagram socket class represents a connection-less socket for sending or receiving datagram packets. The datagram socket object is the data container used to send or receive the datagram packets. No guarantee of its content, arrival or arrival time It defines four public constructors: DatagramSocket() throws SocketException -> Creates a DatagramSocket bound to any unused port.

Continue… DatagramSocket(int port) throws SocketException -> Creates a DatagramSocket bound to specified port. DatagramSocket(int port, InetAddress ipAddress) throws SocketException -> Constructs a DatagramSocket bound to specified port & InetAddress. DatagramSocket(SocketAddress address) throws SocketException -> Creates a DatagramSocket bound to specified SocketAddress.

DatagramPacket DatagramPacket is a message that can be sent or received When multiple packets are sent, it may arrive in any order Packet delivery is not guaranteed Commonly used constructors : DatagramPacket(byte data[], int size); -> This constructor is used to receive the packets. DatagramPacket(byte data[], int size, InetAddress ipAddress, int port); -> This constructor is used to send the packets .

Receiving D atagramPacket by D atagramSocket Example Program:

Sending DatagramPacket by DatagramSocket Example Program:

Thanking YOU
Tags