rendered paste bodyusing 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());
string Temp;
//System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
string SearchString = "http";
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)
{
Temp = SR.ReadLine().ToLower();
Console.WriteLine(Temp);
if (Temp.IndexOf(SearchString) == -1) Console.WriteLine("Not Found");
if (Temp.IndexOf(SearchString) != -1) Console.WriteLine("Found");
Console.ReadLine();
}
}
catch (SocketException e)
{
Console.WriteLine("Socket Exception: {0}", e.Message);
}
catch (NullReferenceException e)
{
Console.WriteLine("NullReference Exception: {0}", e.Message);
}
Console.ReadLine();
}
}
}