Event when data arrived or server has disconnected

Giganews Newsgroups
Subject: Event when data arrived or server has disconnected
Posted by:  glup (nospam@kahn-gruppe.de)
Date: Mon, 1 Sep 2003

How could my client get a in-time notification when
a) the server has send data ("new data available")
b) the server has disconnected

In-time should mean that I want this information, when the message is
received by the client.

I know delphi uses blocking sockets, but anyhow I need this information.
There is nothing in the FAQ about this but anyhow I belive this is a common
problem so there SHOULD be a "easy" solution.

My example in detail:

The server uses a FTP based protocol and sends sometimes status messages on
the control connection that are not related to a certain FTP command, e.g.
before the server will shutdown to give user a chance to complete their
tasks before shutdown.
If I make after a request-response cycle a ReadLnWait, my application is
blocked until the connection is closed by the server or a he sends a

The server could have a connection timeout activated, on which he
disconnects when the connection was idle a certain amount of time. I want to
visualize the connection state (connected/disconnected). If I use the
OnDisconnect event, it is not fired when the server is disconnecting, but
when I try to send a new command. That's NOT usefull.