var
Domain, Scenery, aHost:
ShortString
;
....
procedure
TForm1
.
Button1Click(Sender: TObject);
begin
Domain :=
'delphikingdom.com'
;
aHost :=
'delphikingdom.com'
;
Scenery :=
'/'
;
ClientSocket1
.
Host := Domain;
ClientSocket1
.
Port :=
80
;
ClientSocket1
.
Open;
end
;
procedure
TForm1
.
ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
var
st1, st2, st3:
string
;
stOut:
string
;
ddBuffer :
array
[
0
..
19
]
of
Char
;
MySocket: TWinSocketStream;
CountReadBytes, i:
Integer
;
begin
MySocket := TWinSocketStream
.
Create(Socket,
60000
);
st1 :=
'GET '
+ Scenery +
' HTTP/1.1'
+ #
10
;
st2 :=
'Host: '
+ aHost + #
10
;
st3 :=
'#10#10'
;
if
MySocket
.
Write
(st1, Length(st1)) >
0
then
if
MySocket
.
Write
(st2, Length(st2)) >
0
then
if
MySocket
.
Write
(st3, Length(st3)) >
0
then
Beep;
while
not
MySocket
.
WaitForData(
100
)
do
Application
.
ProcessMessages;
stOut :=
''
;
repeat
ddBuffer :=
''
;
CountReadBytes := MySocket
.
Read(ddBuffer,
20
);
if
CountReadBytes >
0
then
for
i :=
0
to
CountReadbytes -
1
do
StOut := StOut + ddBuffer[i]
else
begin
ClientSocket1
.
Close;
Break;
end
;
until
Length(stOut) >=
17000
;
MySocket
.
Free;
ShowMessage(StOut);
ClientSocket1
.
Close;
end
;