Code example for DatagramSocket

Methods: close, getSendBufferSize, setSendBufferSize

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