Article View: borland.public.cppbuilder.internet.socket
Article #3070Re: Modify the timeout for open() method
From: Remy Lebeau (TeamB)
Date: Thu, 01 Dec 2005 18:32
Date: Thu, 01 Dec 2005 18:32
28 lines
2085 bytes
2085 bytes
"enzo" <enzo.arlati@aesys.it> wrote in message news:438ed040@newsgroups.borland.com... > I'm using a standard TClientSocket to connect to some servers. > When the server is down the Open() call wait several seconds > before abort for timeout. Are you using the TClientSocket in blocking or non-blocking mode? In non-blocking mode, Open() should be returning almost immediately regardless of whether the connection is successful or not. You will be notified later on if the connection is established or not. You can start a timer as soon as Open() returns, and then disconnect the socket if the timer elapses. If the connection succeeds, stop the timer. In blocking mode, you will have to use a separate worker thread to disconnect the socket if it is not connected after your timeout elapses. Also, try to use the Address property instead of the Host property if you can. The Host property performs a DNS lookup when Open() is called, which takes extra time. The Address property does not perform any DNS lookup. This is because DNS is used to resolve a hostname into an IP address, and the Address property only works with IP addresses so no DNS lookup is needed. Gambit
Technical Details
Message-ID:
<438f4204$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<438ed040@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,234cf6f94ba290e1 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <438ed040@newsgroups.borland.com> Subject: Re: Modify the timeout for open() method Date: Thu, 1 Dec 2005 10:32:42 -0800 Lines: 30 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <438f4204$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1133462020 68.69.17.41 (1 Dec 2005 10:33:40 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail