Code example for DatagramPacket

Methods: getAddressgetOffsetgetPortgetSocketAddress

0
        } 
 
        // now validate we can construct 
        InetSocketAddress theAddress = new InetSocketAddress(InetAddress
                .getLocalHost(), 2067);
        DatagramPacket thePacket = new DatagramPacket(buf, 1, 1, theAddress);
        assertEquals("Socket address not set correctly (1)", theAddress,
                thePacket.getSocketAddress());
        assertEquals("Socket address not set correctly (2)", theAddress,
                new InetSocketAddress(thePacket.getAddress(), thePacket
                        .getPort()));
        assertEquals("Offset not set correctly", 1, thePacket.getOffset());
    } 
 
    /** 
     * @tests java.net.DatagramPacket#getSocketAddress() 
     */ 
    public void test_getSocketAddress() throws IOException { 
        byte buf[] = new byte[1];
        DatagramPacket thePacket = new DatagramPacket(buf, 1);
Connect your IDE to all the code out there  Get Codota for Java