0
 
    private static void initialize() 
    { 
        Socket socket = null;
 
        socket = new Socket();
 
        try 
        { 
            DEFAULT_REUSE_ADDRESS = socket.getReuseAddress();
            DEFAULT_RECEIVE_BUFFER_SIZE = socket.getReceiveBufferSize();
            DEFAULT_SEND_BUFFER_SIZE = socket.getSendBufferSize();
            DEFAULT_KEEP_ALIVE = socket.getKeepAlive();
            DEFAULT_OOB_INLINE = socket.getOOBInline();
            DEFAULT_SO_LINGER = socket.getSoLinger();
            DEFAULT_TCP_NO_DELAY = socket.getTcpNoDelay();
 
            // Check if setReceiveBufferSize is supported. 
            try 
            { 
                socket.setReceiveBufferSize(DEFAULT_RECEIVE_BUFFER_SIZE);
                SET_RECEIVE_BUFFER_SIZE_AVAILABLE = true;
            } 
            catch( SocketException e )
            { 
                SET_RECEIVE_BUFFER_SIZE_AVAILABLE = false;
            } 
 
            // Check if setSendBufferSize is supported. 
            try 
            { 
                socket.setSendBufferSize(DEFAULT_SEND_BUFFER_SIZE);
                SET_SEND_BUFFER_SIZE_AVAILABLE = true;
            } 
            catch( SocketException e )
            { 
                SET_SEND_BUFFER_SIZE_AVAILABLE = false;
            } 
 
            // Check if getTrafficClass is supported. 
            try 
            { 
                DEFAULT_TRAFFIC_CLASS = socket.getTrafficClass();
                GET_TRAFFIC_CLASS_AVAILABLE = true;
            } 
            catch( SocketException e )
            { 
                GET_TRAFFIC_CLASS_AVAILABLE = false;
                DEFAULT_TRAFFIC_CLASS = 0;
            } 
        } 
        catch( SocketException e )
        { 
            throw new ExceptionInInitializerError(e);
        } 
        finally 
        { 
            if( socket != null )
            { 
                try 
                { 
                    socket.close();
                } 
                catch( IOException e )
                { 
                    ExceptionMonitor.getInstance().exceptionCaught(e);
                } 
Stop searching for code, let great code find you!  Add Codota to your java IDE