Solved

TCP/IP waitting time

Posted on 2002-06-12
5
381 Views
Last Modified: 2010-04-04
I am using Indy IdTCPServer and IdTCPClient to build two programs that run on different computers.
Normally, IdTCPClient sends a text to IdTCPServer without problem. Sometimes if the computer that has IdTCPServer is not swithed on then IdTCPClient got error. That is acceptable, but the problem is the program is frozen to waiting the error, it normally waits for more than 15 seconds. I wish the program can only wait for 2 or 3 seconds, that means if it cannot find the destination computer(by computer name or IP address) in 2 or 3 seconds then returns an error immediately. How can I do this?
BTW, I do have to use Indy.

Thank u very much in advance.


Peter
0
Comment
Question by:petershaw9
  • 3
5 Comments
 
LVL 1

Expert Comment

by:_MeSSiah_
ID: 7072578
You can use the ReadTimeout property of TidTCPClient and set it to number of miliseconds.

If you get the error on connecting, try to connect like this:

idTCPClient1.Connect(3000);

The 3000 is a timeout in miliseconds. In my case, the client will wait exactly 3 seconds for the server to accept the connection.

Also a small off topic tip: Drop a TidAntiFreeze component on your client's main form, so the application won't freeze during transmissions and socket operations.
0
 
LVL 1

Expert Comment

by:_MeSSiah_
ID: 7072582
Oh, i forgot...like Connect method, other functions (like ReadLn for ex.) have an ATimeOut parameter, that is set to -1 by default. You can override it mannualy on each call or use ReadTimeout property.

(i'm talking about Indy 9.x and higher)
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 7074445
or you can do all these operations in a separate thread of its own.
0
 

Author Comment

by:petershaw9
ID: 7077815
Hi,
Firstly, thank u for your help.
I am using Delphi 6. The Indy's TCPClient has not ReadTimeOut property. and the connect method does not have parameters required. I am first time do TCP/IP programming. I firstly use TCPClient.connect method to connect to TCPSever. and then use TCPClient.WriteLn to send msg. The problem occurred at Connect method. So do I have to connect first? I guess, Yes.

If Delphi 6 does not use Indy 9.x, is any other way to solve the problem or I can download Indy 9.x?


peter
0
 
LVL 1

Accepted Solution

by:
_MeSSiah_ earned 200 total points
ID: 7077918
Delphi 6 comes with Indy 8 components. You can download Indy 9.x from http://www.nevrona.com/Indy

Before installing Indy 9.x, you must remove Indy 8 that was installed with Delphi 6. You can do this in Add/Remove Programs. You just modify your Delphi 6 instalation and remove Indy packages from the install list. Complete instalation notes for D6 are on the Indy download page (http://www.nevrona.com/Indy/download90.html).

For a start, you only need to download Indy 9.0.3 Automated NetInstall at http://www.nevrona.com/Indy/downloads/9_00_03/IndyNet9_00_03.EXE

When you have successfuly installed Indy, just use my previous directions for the timeout.

If you get the error at Connect, just connect with a timeout parameter set, for ex.

idTCPClient1.Connect(3000);  //3 sec. timeout
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now