hi list,
i wonder if this is a problem or just my poor memory,
but as far as i can remember the two lines (xml type:)
used to show the same output
thanks for any response,
++dent
--
"They that can give up liberty to obtain a little temporary safety
deserve neighter liberty nor safety" - Benjamin Franklin
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Net.Sockets;
using System.Xml;
public class Jabber
{
public static void Main()
{
TcpClient clnt = new TcpClient("www.go-mono.com", 80);
NetworkStream stream = clnt.GetStream();
test_1(stream);
test_2(stream);
}
static void send_req(NetworkStream stream)
{
string str = "GET /index.rss HTTP/1.0\r\nHost:
www.go-mono.com\r\n\r\n";
byte[] buf = System.Text.Encoding.ASCII.GetBytes(str);
Console.WriteLine();
Console.WriteLine("Transmitting ...");
stream.Write(buf, 0, buf.Length);
}
static void test_1(NetworkStream stream)
{
send_req(stream);
Console.WriteLine("Reading (Read line) ...");
StreamReader reader = new StreamReader (stream);
string str;
// skip HTTP header
while ((str = reader.ReadLine()) != null) {
if (str == "")
break;
}
//skip processing instruction
str = reader.ReadLine();
str = reader.ReadLine();
Console.WriteLine(str);
StringReader str_reader = new StringReader (str);
XmlTextReader xml = new XmlTextReader(str_reader);
xml.Read();
Console.WriteLine ("xml type: {0} name: {1}\n", xml.NodeType,
xml.Name);
}
static void test_2(NetworkStream stream)
{
send_req(stream);
Console.WriteLine("Reading (XmlTextReader) ...");
StreamReader reader = new StreamReader (stream);
string str;
// skip HTTP header
while ((str = reader.ReadLine()) != null) {
if (str == "")
break;
}
//skip processing instruction
str = reader.ReadLine();
XmlTextReader xml = new XmlTextReader(stream);
xml.Read();
Console.WriteLine ("xml type: {0} name: {1}\n", xml.NodeType,
xml.Name);
}
}