• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2221
  • Last Modified:

HOW TO USE: TIDTCPCLIENT1.CheckForDisconnect() and TIDTCPCLIENT1.CheckResponse()

how to use this functions below, somebody can give a example:

TIDTCPCLIENT1.CheckForDisconnect();
TIDTCPCLIENT1.CheckForGracefulDisconnect();
TIDTCPCLIENT1.CheckResponse()
0
rafaelrgl
Asked:
rafaelrgl
1 Solution
 
TheRealLokiSenior DeveloperCommented:
TIDTCPCLIENT1.CheckForDisconnect();
is used internally in the "Connected" property (and therfore also in the "Disconnect" method)
and various "Read" methods.
You do not need to call this yourself.

TIDTCPCLIENT1.CheckForGracefulDisconnect();
Determines if the peer has been gracefully disconnected
it calls ReadFromStack with a very short timeout, which subsequently validates the connection.
It is safe to call this before a Read, but you can still get a disconnect while receiving data
e.g.
try
  IdTCPClient1.CheckForGracefulDisconnect(true);
  S := IdTCPClient1.ReadLn;

this could return the following exceptions
except
  on EIdConnClosedGracefully do // connection closed gracefully
  on EIdNotConnected: // not connected....
end;


TIDTCPCLIENT1.CheckResponse()
  this just looks to see if 1 smallint is in an array of allowed smallints
e.g. if "2" is in [0,1,3,4,5]
I've only ever seen this used internally by Indy, but it's a compact function that you could use for your own purposes, although I don't see any obvious place in the Indy stuff I do.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now