Code example for DatagramSocket

Methods: getBroadcast, setBroadcast

0
        theSocket.setBroadcast(true);
        theSocket.connect(new InetSocketAddress(InetAddress.getByAddress(theBytes), ports[2]));
    } 
 
    public void test_getBroadcast() throws Exception { 
        DatagramSocket theSocket = new DatagramSocket();
        theSocket.setBroadcast(true);
        assertTrue("getBroadcast false when it should be true", theSocket.getBroadcast());
        theSocket.setBroadcast(false);
        assertFalse("getBroadcast true when it should be False", theSocket.getBroadcast());
    } 
 
    public void test_setTrafficClassI() throws Exception { 
        int IPTOS_LOWCOST = 0x2;
        int IPTOS_RELIABILTY = 0x4;
        int IPTOS_THROUGHPUT = 0x8;
        int IPTOS_LOWDELAY = 0x10;
        int[] ports = Support_PortManager.getNextPortsForUDP(2);
 
        new InetSocketAddress(InetAddress.getLocalHost(), ports[0]);
        DatagramSocket theSocket = new DatagramSocket(ports[1]);