Code example for DatagramSocket

Methods: close, getSoTimeout, setSoTimeout

0
    } 
 
    public void test_getSoTimeout() throws Exception { 
        // Test for method int java.net.DatagramSocket.getSoTimeout() 
        int portNumber = Support_PortManager.getNextPortForUDP();
        ds = new java.net.DatagramSocket(portNumber);
        ds.setSoTimeout(100);
        assertEquals("Returned incorrect timeout", 100, ds.getSoTimeout());
        ds.close();
        try { 
            ds.getSoTimeout();
            fail("SocketException was not thrown.");
        } catch(SocketException se) {
            //expected 
        } 
    } 
 
    public void test_receiveLjava_net_DatagramPacket() throws Exception { 
        // Test for method void 
        // java.net.DatagramSocket.receive(java.net.DatagramPacket)