I have a TIdTCPClient which is trying to connect to a host which is not online.
UPDATE:
After diving a bit deeper into WINSOCK2 it seems like this is indeed an issue which is depending on your operating system. Maybe there will be a fix in a future release. (See the comments of this question for more details)
Setup:
The ConnectTimeout is set to 5000 ms so I would expect to get at least a ConnectTimeout after 5 seconds. However on my current machine it takes over 20 seconds to receive that Timeout.
So far I see that the ConnectionTimeout is handled correctly but on TIdIOHandlerStack.ConnectClient there is an WaitFor on the thread which performs the actual connection attempt. I think this is causing the delayed connection timeout, but I don't know what I could do about that. Any Ideas?
Code:
procedure TForm1.btn1Click(Sender: TObject);
begin
try
Self.mmo1.Lines.Add(TimeToStr(now));
Self.idtcpclnt1.Host := '192.148.89.112';
Self.idtcpclnt1.Port := 9200;
Self.idtcpclnt1.Connect;
except on E: Exception do
Self.mmo1.Lines.Add(TimeToStr(now)+ ' : '+E.Message);
end;
end;
procedure TForm1.idtcpclnt1Status(ASender: TObject; const AStatus: TIdStatus;
const AStatusText: string);
begin
Self.mmo1.Lines.Add(TimeToStr(now)+ ' : ' +AStatusText);
end;
Result of this code:
If the destination is a firewall and the firewall is enabled, you must disable the firewall.
Instead of disabling the firewall, you must open the appropriate ports. However, the risks are high .
Because it becomes more permeable .( Hack )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.