Code example for DatagramSocket

Methods: close, getReceiveBufferSize, setReceiveBufferSize

0
        } 
    } 
 
    public void test_getReceiveBufferSize() throws Exception { 
        int portNumber = Support_PortManager.getNextPortForUDP();
        ds = new java.net.DatagramSocket(portNumber);
        ds.setReceiveBufferSize(130);
        assertTrue("Incorrect buffer size", ds.getReceiveBufferSize() >= 130);
        ds.close();
        try { 
            ds.getReceiveBufferSize();
            fail("SocketException was not thrown.");
        } catch(SocketException se) {
            //expected 
        } 
    } 
 
    public void test_getSendBufferSize() throws Exception { 
        int portNumber = Support_PortManager.getNextPortForUDP();
        ds = new java.net.DatagramSocket(portNumber);
        ds.setSendBufferSize(134);