Main Site Documentation

Domino, Ethernet Shield & HTTPWebRequest Class Question


#1

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. :slight_smile:

My first experiment was inspired by the excellent NOAA Weather API provided by Chris on Fezzer.com (http://www.fezzer.com/project/96/noaa-weather-api/). 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 (http://www.csharp-station.com/HowTo/HttpWebFetch.aspx) 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


#2

OK … Let’s try a different approach.

I have been trying to use the HTTPWebRequest class with a Domino and Ethernet shield. I keep getting a “System not supported” exception at run time. Is this telling me that the Domino doesn’t support this class?


#3

You are right.
Domino uses W5100 sockets which are in the GHI assembly. HttpWebRequest uses MS sockets. I have just ported HttpListener which uses W5100 socket for GHI. HttpWebRequest is in the same assembly as HttpListener, so I guess the next step would be to add HttpWebRequest that will use W5100 sockets. Gus?


#4

Architect … Thank you!


#5

Someting is being cooked for HTTP support. 8)


#6

…yes but you only have to wait for a bit and this will change :slight_smile:


#7

Great!

Joe,
I have send you latest update last night.


#8

Joe and Gus … Thank you very much! This is so cool! Your products just keep getting better and better. ;D