H
http1
Unregistered / Unconfirmed
GUEST, unregistred user!
DELPHI的例子
while (not Terminated) and ClientSocket.Connecteddo
begin
try
Stream := TWinSocketStream.Create(ClientSocket, 60000);
try
FillChar(Buffer, 10, 0);
{ initialize the buffer }
{ give the client 60 seconds to start writing }
if Stream.WaitForData(60000) then
begin
if Stream.Read(Buffer, 10) = 0 then
{ if can抰 read in 60 seconds }
ClientSocket.Close;
{ close the connection }
{ now process the request }
...
end
else
ClientSocket.Close;
{ if clientdo
esn抰 start, close }
finally
Stream.Free;
end;
except
HandleException;
end;
end;
奇怪的是,为什么Stream := TWinSocketStream.Create(ClientSocket, 60000)在循环内建立
而不是循环外建立呢?在内建立,变成当接收完,就释放,然后循环再建,这时候如果客户发
数据过来,不就出错了吗????
while (not Terminated) and ClientSocket.Connecteddo
begin
try
Stream := TWinSocketStream.Create(ClientSocket, 60000);
try
FillChar(Buffer, 10, 0);
{ initialize the buffer }
{ give the client 60 seconds to start writing }
if Stream.WaitForData(60000) then
begin
if Stream.Read(Buffer, 10) = 0 then
{ if can抰 read in 60 seconds }
ClientSocket.Close;
{ close the connection }
{ now process the request }
...
end
else
ClientSocket.Close;
{ if clientdo
esn抰 start, close }
finally
Stream.Free;
end;
except
HandleException;
end;
end;
奇怪的是,为什么Stream := TWinSocketStream.Create(ClientSocket, 60000)在循环内建立
而不是循环外建立呢?在内建立,变成当接收完,就释放,然后循环再建,这时候如果客户发
数据过来,不就出错了吗????