delphi - IdTCPClient cannot connect through weak internet connections -
i have simple procedure uses tidtcpclient connect server. purpose try reach server , block thread until connection established. works stable internet connections. problem is, when client executed on computers (all of these computers have slow or unstable internet connection mobile 3g or in small distant towns), fails connect "connect timed out" exception. @ same time abovementioned computers run browsers, im clients, etc, , these applications work fine. server application shows no sign of new client.
here procedure:
procedure connecttoserver; begin entercriticalsection(cs_connect); try while not client.connected begin log('connection attempt...'); client.port := <port goes here>; client.ipversion := id_ipv4; client.host := '<ip address here>'; client.connecttimeout := 11500; try client.connect; except on e: exception log('exception: ' + e.tostring); end; if client.connected begin log('connected after ' + inttostr(attempts) + ' failed attempts'); client.iohandler.writeln(msg_hello); attempts := 0; exit; end; inc(attempts); log('connection attempt failed'); sleep( min(attempts * 1000, 50000) ); end; leavecriticalsection(cs_connect); end; end;
you not doing wrong (though use of connected
redundant). indy uses same socket api other apps use. use same underlying connect()
function. problem not indy, os itself. since have weak signal, hit/miss when given connection succeed or fail.
Comments
Post a Comment