Solved

TCP/IP waitting time

Posted on 2002-06-12
5
387 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month6 days, 23 hours left to enroll

623 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