Code example for DatagramSocket

Methods: close, getSoTimeout, setSoTimeout

0
    } 
 
    public void test_setSoTimeoutI() throws Exception { 
        // Test for method void java.net.DatagramSocket.setSoTimeout(int) 
        int portNumber = Support_PortManager.getNextPortForUDP();
        ds = new java.net.DatagramSocket(portNumber);
        ds.setSoTimeout(5000);
        assertTrue("Set incorrect timeout", ds.getSoTimeout() >= 5000);
        ds.close();
        try { 
            ds.setSoTimeout(100);
            fail("SocketException was not thrown.");
        } catch(SocketException se) {
            //expected 
        } 
    } 
 
    public void test_ConstructorLjava_net_DatagramSocketImpl() { 
        class testDatagramSocket extends DatagramSocket {
            public testDatagramSocket(DatagramSocketImpl impl){
               super(impl);