Hello Everyone …
I have a question about networking.
Recently, I downloaded and installed the most recent version of the GHI NETMF SDK. After updating the Domino’s firmware, I began messing around with an Ethernet shield. I had no problem getting the SocketServer example to work, so I decided to try what I hoped would be a few simple experiments.
My first experiment was inspired by the excellent NOAA Weather API provided by Chris on Fezzer.com ([url]http://www.fezzer.com/project/96/noaa-weather-api/[/url]). The API is very comprehensive and intended for FEZ Cobra/ChipworkX … my goal is a lot simpler.
As a first step, all I want to do is fetch the XML for a single ASOS site using the HTTPWebRequest class. I found some sample code on the web ([url]http://www.csharp-station.com/HowTo/HttpWebFetch.aspx[/url]) which worked perfectly in .NET on a PC.
Initializing the W5100 wasn’t difficult, I borrowed part of the SocketServer example code:
byte[] ip = { 192, 168, 1, 110 };
byte[] subnet = { 255, 255, 255, 0 };
byte[] gateway = { 192, 168, 1, 1 };
byte[] mac = { 222, 173, 190, 239, 254, 237 };
// Set up hardware
WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10, (Cpu.Pin)FEZ_Pin.Digital.Di9, true);
NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);
NetworkInterface.EnableStaticDns(new byte[] { 192, 168, 1, 1 });
After adding the required assemblies and namespaces, the HTTPWebRequest part of the code was pretty straight forward, too:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.weather.gov/xml/current_obs/kunv.xml");
// Execute the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// Read data via the response stream
Stream resStream = response.GetResponseStream();
My question is, what do I have to do in between the hardware initialization and the HTTP request as far as setting up a socket, etc is concerned? I tried searching the forum and on the web, but I didn’t find anything that is really helpful to me. My networking experience (Ethernet Shield + Arduino) is limited, so I’d appreciate any specific tips or suggested reading.
Thanks,
Al