Code example for DatagramPacket

Methods: getSocketAddresssetSocketAddress

0
        DatagramPacket thePacket = new DatagramPacket(buf, 1);
 
        // Validate get returns the value we set 
        InetSocketAddress theAddress = new InetSocketAddress(InetAddress
                .getLocalHost(), 0);
        thePacket = new DatagramPacket(buf, 1);
        thePacket.setSocketAddress(theAddress);
        assertEquals("Socket address not set correctly (1)", theAddress,
                thePacket.getSocketAddress());
    } 
 
    /** 
     * @tests java.net.DatagramPacket#setSocketAddress(java.net.SocketAddress) 
     */ 
    public void test_setSocketAddressLjava_net_SocketAddress() 
            throws IOException { 
 
        @SuppressWarnings("serial") 
        class UnsupportedSocketAddress extends SocketAddress {