{"record":{"id":"44c5b440f11df27c","repo":"TechnitiumSoftware/DnsServer","slug":"valid-range-is-from-8-kb-to-65536-kb","errorCode":null,"errorMessage":"Valid range is from 8 KB to 65536 KB.","messagePattern":"Valid range is from 8 KB to 65536 KB\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/DnsServer.cs","lineNumber":7572,"sourceCode":"                    throw new ArgumentOutOfRangeException(nameof(QuicMaxInboundStreams), \"Valid range is from 1 to 1000.\");\n\n                _quicMaxInboundStreams = value;\n            }\n        }\n\n        public int ListenBacklog\n        {\n            get { return _listenBacklog; }\n            set { _listenBacklog = value; }\n        }\n\n        public int UdpSendBufferSizeKB\n        {\n            get { return _udpSendBufferSizeKB; }\n            set\n            {\n                if ((value < 8) || (value > 65536))\n                    throw new ArgumentOutOfRangeException(nameof(UdpSendBufferSizeKB), \"Valid range is from 8 KB to 65536 KB.\");\n\n                _udpSendBufferSizeKB = value;\n            }\n        }\n\n        public int UdpReceiveBufferSizeKB\n        {\n            get { return _udpReceiveBufferSizeKB; }\n            set\n            {\n                if ((value < 8) || (value > 65536))\n                    throw new ArgumentOutOfRangeException(nameof(UdpReceiveBufferSizeKB), \"Valid range is from 8 KB to 65536 KB.\");\n\n                _udpReceiveBufferSizeKB = value;\n            }\n        }\n\n        public ushort MaxConcurrentResolutionsPerCore","sourceCodeStart":7554,"sourceCodeEnd":7590,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/DnsServer.cs#L7554-L7590","documentation":"Thrown by the UdpSendBufferSizeKB setter. It configures the SO_SNDBUF socket buffer size (in KB) used for outbound UDP DNS responses. The setter enforces [8, 65536] KB (i.e. 8 KB to 64 MB). Anything outside that band throws ArgumentOutOfRangeException on assignment from the settings API or config loader.","triggerScenarios":"Assigning DnsServer.UdpSendBufferSizeKB a value < 8 or > 65536. Occurs via WebServiceSettingsApi.cs:875 settings update or via a binary config int read that yields an out-of-range value.","commonSituations":"Confusing KB and bytes (e.g. passing 8192 meaning 8 KB in bytes -> 8192 KB = 8 MB, which is valid but unintended; or passing 8 meaning bytes -> 8 KB). Setting 0 or 1 to 'disable' buffering. Raising the buffer to absorb large DNS responses but exceeding the 64 MB cap.","solutions":["Provide a value in KB within 8..65536 (e.g. 1024 for a 1 MB send buffer).","Confirm the unit is kilobytes, not bytes — multiply/divide by 1024 accordingly.","For high-throughput servers, a value such as 4096-8192 KB is typical; never exceed 65536.","Validate config ints before assignment so a corrupt value does not crash settings load."],"exampleFix":"// before\n_dnsServer.UdpSendBufferSizeKB = 8192; // meant 8KB in bytes, actually 8MB (valid but wrong) / or 4 (throws)\n\n// after\n_dnsServer.UdpSendBufferSizeKB = 1024;  // 1 MB, clearly within 8..65536 KB","handlingStrategy":"validation","validationCode":"static int ClampBufferKB(int value) =>\n    value < 8 ? 8 : value > 65536 ? 65536 : value;\n\n_dnsServer.UdpSendBufferSizeKB = ClampBufferKB(parsedKB);","typeGuard":"static bool IsValidBufferSizeKB(int value) => value >= 8 && value <= 65536;","tryCatchPattern":"try { _dnsServer.UdpSendBufferSizeKB = parsedKB; }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == nameof(DnsServer.UdpSendBufferSizeKB))\n{ _dnsServer.UdpSendBufferSizeKB = 1024; }","preventionTips":["Confirm the unit is kilobytes, not bytes.","Keep send and receive buffer sizes consistent.","Validate config ints to [8, 65536] KB before assignment."],"tags":["dns","udp","buffer","socket","configuration","argumentoutofrange"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}