Question: The DatagramPacket class has two constructors (see Table 25.11). Which constructor can be used as a sending packet? Table 25.11 Some methods in DatagramPacket class

The DatagramPacket class has two constructors (see Table 25.11). Which constructor can be used as a sending packet?

Table 25.11 Some methods in DatagramPacket class public final class java.net.DatagramPacket extends java.lang.Object // Constructors public DatagramPacket (byte [] data, int length) public DatagramPacket (byte [] data, int length, InetAddress remoteAddr, int remotePort) // Instance Methods public InetAddress getAddress () public int getPort () public byte [] getData () public

Table 25.11 Some methods in DatagramPacket class public final class java.net.DatagramPacket extends java.lang.Object // Constructors public DatagramPacket (byte [] data, int length) public DatagramPacket (byte [] data, int length, InetAddress remoteAddr, int remotePort) // Instance Methods public InetAddress getAddress () public int getPort () public byte [] getData () public int getLength ()

Step by Step Solution

3.41 Rating (164 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

We need to use the second constructor in Table 2511 which includes the IP address and the ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Networking Questions!