using System; using System.Collections.Generic; using System.Text; using System.Net.Sockets; using System.Net; using System.IO; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { TcpClient Request = new TcpClient(); string RemoteAddress = "www.google.com"; Int16 Port = 80; NetworkStream Stream; byte[] Bytes = new byte[1024]; string Data = "GET /index.html HTTP/1.0\r\n\r\n"; Bytes = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray()); char[] CharBuffer = new char[1024]; byte[] Buffer = new byte[1024]; string Temp; System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); try { Request.Connect(RemoteAddress, Port); Stream = Request.GetStream(); StreamReader SR = new StreamReader(Stream); StreamWriter SW = new StreamWriter(Stream); Console.WriteLine("Connected to: {0}:{1}", RemoteAddress, Port); Stream.Write(Bytes, 0, Bytes.Length); Stream.Flush(); while (Stream != null) { Stream.Read(Buffer, 0, (Buffer.Length / 6)); Temp = enc.GetString(Buffer); Console.WriteLine(Temp); Console.ReadLine(); } } catch (SocketException e) { Console.WriteLine("Socket Exception: {0}", e.Message); } catch (NullReferenceException e) { Console.WriteLine("NullReference Exception: {0}", e.Message); } Console.ReadLine(); } } }