PROGRAM downloadwebpage;
USES
  Crt,SysUtils,CTypes,modaslTCPSocket,Classes;
VAR
  aBuf_List : TStringList;
  Sock : TBuFTCPClientSocket;
  aBuf : ansistring;
  atxt : text;
  count : longint;
BEGIN
 count:=0;
 assign(atxt,'connectdata.txt');
 rewrite(atxt);
// repeat
 Try
  Sock:=TBufTCPClientSocket.Create;
(*
  Sock.Connect('www.surfjunky.com','80');
  Sock.WriteLn('GET /members/surfjunky.php HTTP/1.1');
  Sock.WriteLn('Accept-Language: en-us');
  Sock.WriteLn('User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)');
  Sock.WriteLn('Host: www.surfjunky.com');
  Sock.WriteLn('Connection: Close'+#13+#10+#13+#10);
*)

  Sock.Connect('www.surfjunky.com','80');
  Sock.Writeln('POST /verify.php HTTP/1.1'+#13+#10);
  Sock.WriteLn('Accept-Language: en-us'+#13+#10);
  Sock.WriteLn('User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)'+#13+#10);
  Sock.Writeln('Host: www.surfjunky.com'+#13+#10);
  Sock.Writeln('Content-Type: application/x-www-form-urlencoded'+#13+#10);
  Sock.Writeln('Content-Length: 31'+#13+#10);
  Sock.Writeln(#13+#10);
  Sock.Writeln('username=bliss&password=critter');
  Sock.WriteLn('Connection: Close'+#13+#10+#13+#10);

  abuf := '';
  Sock.Readln(aBuf);
  While aBuf <> '' do begin
      Sock.Readln(aBuf);
      writeln(atxt,abuf);
      writeln(abuf);
  end;

  Sock.Connect('www.surfjunky.com','80');
  Sock.WriteLn('GET /members/surfjunky.php HTTP/1.1'+#13+#10);
  Sock.WriteLn('Accept-Language: en-us'+#13+#10);
  Sock.WriteLn('User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)'+#13+#10);
  Sock.WriteLn('Host: www.surfjunky.com'+#13+#10);
  Sock.WriteLn('Connection: Close'+#13+#10+#13+#10);

  abuf := '';
  Sock.Readln(aBuf);
  While aBuf <> '' do begin
      Sock.Readln(aBuf);
      writeln(atxt,abuf);
      writeln(abuf);
  end;


  Sock.Destroy;
  except
    on E:Exception do Writeln( E.Message );
  end;
  inc(count);
  writeln(count);
//until 0 = 1;
end.

