Web Technologies Unit 2 Part 2
Web Technologies Unit 2 Part 2
SocketAddress getLocalSocketAddress() It returns the address of the endpoint the socket is bound to.
int getPort() It returns the port number to which the socket is connected.
int getReceiverBufferSize() It gets the value of the SO_RCVBUF option for this DatagramSocket that is the buffer size
used by the platform for input on the DatagramSocket.
• DatagramPacket is a message that can be sent or 1) InetAddress getAddress() It returns the IP address of the machine to
which the datagram is being sent or from
received. which the datagram was received.
Additionally, packet delivery is not guaranteed. 4) int getOffset() It returns the offset of the data to be sent or
the offset of the data received.
• Commonly used Constructors of DatagramPacket class 5) int getPort() It returns the port number on the remote
host to which the datagram is being sent or
• DatagramPacket(byte[] barr, int length): it creates a from which the datagram was received.
datagram packet. This constructor is used to receive the
packets. 6) SocketAddress getSocketAddress() It gets the SocketAddress (IP address + port
number) of the remote host that the packet
• DatagramPacket(byte[] barr, int length, InetAddress is being sent to or is coming from.
address, int port): it creates a datagram packet. This 7) void setAddress(InetAddress iaddr) It sets the IP address of the machine to
which the datagram is being sent.
constructor is used to send the packets.
8) void setData(byte[] buff) It sets the data buffer for the packet.