For your WWW systems, you will need to set up a Web client, as well as a procedure for making Web requests and getting responses. The following examples demonstrate a Web client and Web request procedure.
using System;
using System.Net;
using System.Text;
using System.IO;
namespace Client.Chapter_14___Networking_and_WWW_Connections
{
class MyWebClient
{
[STAThread]
static void Main(string[] args)
{
WebClient MyClient = new WebClient();
Stream MyStream = MyClient.OpenRead("http://www.MyWeb.com");
StreamReader MyReader = new StreamReader(MyStream);
Console.WriteLine(MyReader.ReadLine());
MyStream.Close();
}
}
}
using System; using System.Net; using System.IO; namespace Client.Chapter_14___Networking_and_WWW_Connections { class Class1 { [STAThread] static void Main(string[] args) { WebRequest MyRequest = WebRequest.Create("http://www.MyWeb.com"); WebResponse MyResponse = MyRequest.GetResponse(); Stream MyStream = MyResponse.GetResponseStream(); StreamReader MyReader = new StreamReader(MyStream); string MyWebLine; while ((MyWebLine = MyReader.ReadLine()) != null) { Console.WriteLine(MyWebLine); } MyStream.Close(); } } }