a question about TIdIOHandlerStack.Connected

Giganews Newsgroups
Subject: a question about TIdIOHandlerStack.Connected
Posted by:  jvlad (dm…@yandex.ru)
Date: Sat, 15 Jan 2011

Please take a look at the TIdIOHandlerStack.Connected implementation:

function TIdIOHandlerStack.Connected: Boolean;
begin
  ReadFromSource(False, 0, False);
  Result := inherited Connected;
end;

suppose the socket was connected and later server disconnected it with
claling shutdown(read/write) and closesocket.
Now we're about to check conection status, so we call IO's Connected() and
it calls ReadFromSource this method runs select recognizes that the socket
is not readable anymore so it returns -1. As you can see this fact is
ignored here. Wouldn't it be better either not to call ReadFromSource or use
the returning value?
Seems it should update FClosedGracefully property or not waste time calling
select.

-

Replies