{"id":785,"date":"2009-06-04T20:24:58","date_gmt":"2009-06-05T01:24:58","guid":{"rendered":"http:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/785"},"modified":"2009-06-04T20:24:58","modified_gmt":"2009-06-05T01:24:58","slug":"a-forgetful-dsl-modem","status":"publish","type":"post","link":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/785","title":{"rendered":"A forgetful DSL modem…."},"content":{"rendered":"

Our household DSL modem, which is generally very reliable, occasionally, and mysteriously seems to forget a setting that I like to enable. I don\u2019t know why, and I\u2019ve never determined whether there\u2019s a pattern to the loss or not (like maybe it\u2019s every 30 days or some crazy thing like that).<\/p>\n

Tonight, I finally decided to attempt to fix the problem in the simplest way I knew how: write some code.<\/p>\n

Thankfully, the DSL modem has a simple web based management system with basic authentication.<\/p>\n

So, I\u2019ve set up a scheduled task on my Windows Home Server every 45 minutes to call into this console application:<\/p>\n

using <\/span>System;\nusing <\/span>System.Net;\nusing <\/span>System.IO;\n\nnamespace <\/span>SendHttpCommand\n{\n    class <\/span>Program\n    <\/span>{\n        static int <\/span>Main(string<\/span>[] args)\n        {\n            if <\/span>(args.Length != 3)\n            {\n                Console<\/span>.WriteLine("SendHttpCommand requires 3 parameters in this order:"<\/span>);\n                Console<\/span>.WriteLine("    username"<\/span>);\n                Console<\/span>.WriteLine("    password"<\/span>);\n                Console<\/span>.WriteLine("    url"<\/span>);\n                return <\/span>-1;\n            }\n            Uri <\/span>uri = new <\/span>Uri<\/span>(args[2]);\n            HttpWebRequest <\/span>request = HttpWebRequest<\/span>.Create(uri) as <\/span>HttpWebRequest<\/span>;\n            request.Credentials = new <\/span>NetworkCredential<\/span>(args[0], args[1]);\n            HttpWebResponse <\/span>response = request.GetResponse() as <\/span>HttpWebResponse<\/span>;\n            try\n            <\/span>{\n                if <\/span>(response != null<\/span>)\n                {\n                    using <\/span>(Stream <\/span>receiveStream = response.GetResponseStream())\n                    {\n                        StreamReader <\/span>readStream = new <\/span>StreamReader<\/span>(receiveStream);\n                        string <\/span>result = readStream.ReadToEnd();\n                        Console<\/span>.WriteLine(result);\n                    }\n\n                }\n            }\n            catch <\/span>{ }\n            finally\n            <\/span>{\n                response.Close();\n            }\n\n            return <\/span>0;\n        }\n    }\n}<\/pre>\n

<\/a><\/p>\n

<\/a><\/p>\n

It literally was 10 minutes of coding, and 2 for testing. And now the DSL modem setting should generally always be set the way I like it (except for the 45 minute window). The program could be smaller by removing the response reading portion \u2013 but I thought it was more interesting that way, so I left it in. <\/p>\n","protected":false},"excerpt":{"rendered":"

Our household DSL modem, which is generally very reliable, occasionally, and mysteriously seems to forget a setting that I like to enable. I don\u2019t know why, and I\u2019ve never determined whether there\u2019s a pattern to the loss or not (like maybe it\u2019s every 30 days or some crazy thing like that). Tonight, I finally decided […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[4],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pd5QIe-cF","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":688,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/688","url_meta":{"origin":785,"position":0},"title":"Calculating the distance between two Zip Codes in C#","date":"January 24, 2009","format":false,"excerpt":"How far is it from the USA Zip code 90210 to 73487 (by drawing a line, not by driving)? Unfortunately, there are many classes built into the .NET framework, but a zip code distance calculator isn\u2019t included. So, you\u2019d be forced to roll your own if you want to programatically\u2026","rel":"","context":"In "Coding"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2009\/01\/image17.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1773,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1773","url_meta":{"origin":785,"position":1},"title":"AV Club \/ Our home setup 2012","date":"December 12, 2012","format":false,"excerpt":"I\u2019ve done a lot of reworking of our computers and network recently and thought I\u2019d post some details about the various physical and digital parts that make our humble WiredPrairie home work. Using Google Docs, I created a labeled diagram with most of the moving parts of our house (WOW,\u2026","rel":"","context":"In "Recommendations"","img":{"alt_text":"Home Setup","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2012\/12\/Home-Setup_thumb1.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":159,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/159","url_meta":{"origin":785,"position":2},"title":"In an alternate Universe, .NET code executes in parallel","date":"April 28, 2008","format":false,"excerpt":"Actually, it's right here as the Microsoft Parallel Extensions to the .NET 3.5 Framework Dec. 2007 CTP (what a mouthful!). If you're not familiar with these extensions, the brief summary is simple (straight from MSDN): Parallel Extensions to the .NET Framework is a managed programming model for data parallelism, task\u2026","rel":"","context":"In "Coding"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1597,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1597","url_meta":{"origin":785,"position":3},"title":"Paging Data with SQL Server Compact","date":"April 1, 2012","format":false,"excerpt":"If you\u2019re using SQL Server Compact Editition version 4 or higher, there\u2019s finally a decent and efficient way to do data paging: var streets = db.Query(@\"SELECT * FROM StreetNames ORDER BY Id OFFSET @offset ROWS FETCH NEXT @rows ROWS ONLY\", new { offset = group * GroupSize, rows = GroupSize\u2026","rel":"","context":"In "Coding"","img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2012\/04\/image9.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1924,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1924","url_meta":{"origin":785,"position":4},"title":"PRTG Network Monitor, Part 2","date":"July 19, 2013","format":false,"excerpt":"Since my last post on the PRTG monitor, I\u2019ve added some more probes (thanks to their offer of a free upgrade to 30 sensors). However, before I got started, the monitor showed that the system health had an alert: I clicked on the red alert box, and the detail page\u2026","rel":"","context":"In "General"","img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2013\/07\/image_thumb6.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1442,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1442","url_meta":{"origin":785,"position":5},"title":"Nest Thermostat API\/Protocol","date":"January 8, 2012","format":false,"excerpt":"While Nest Labs hasn\u2019t released a formal (documented & supported) API, I thought I\u2019d do a bit of digging to see how they\u2019re using the network and what might be achievable. A few things are going on, the majority as you\u2019d probably expect. The web interface is using a long\u2026","rel":"","context":"In "Coding"","img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2012\/01\/image_thumb7.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/posts\/785"}],"collection":[{"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/comments?post=785"}],"version-history":[{"count":0,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/posts\/785\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/media?parent=785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/categories?post=785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/tags?post=785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}