Code example for DatagramPacket

Methods: getAddressgetPortgetSocketAddress

0
        } 
 
        // Now validate we can construct 
        InetSocketAddress theAddress = new InetSocketAddress(InetAddress
                .getLocalHost(), 2067);
        DatagramPacket thePacket = new DatagramPacket(buf, 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()));
    } 
 
    /** 
     * @tests java.net.DatagramPacket#DatagramPacket(byte[], int, int, 
     *        java.net.SocketAddress) 
     */ 
    public void test_Constructor$BIILjava_net_SocketAddress() 
            throws IOException { 
        @SuppressWarnings("serial") 
Contextual code suggestions in your IDE  Get Codota for Java