Code example for DatagramSocket

Methods: getBroadcastgetLocalAddressgetLocalPort

            public UnsupportedSocketAddress() { 
        DatagramSocket ds = new DatagramSocket(new InetSocketAddress(
                InetAddress.getLocalHost(), 0));
        assertTrue("Created socket with incorrect port", ds.getLocalPort() != 0);
        assertEquals("Created socket with incorrect address", InetAddress
                .getLocalHost(), ds.getLocalAddress());
        try { 
            ds = new UnsupportedSocketAddress());
            fail("No exception when constructing datagramSocket with unsupported SocketAddress type");
        } catch (IllegalArgumentException e) {
            // Expected 
        // regression for HARMONY-894 
Stop searching for code, let great code find you!  Add Codota to your java IDE