Solved

TCP/IP waitting time

Posted on 2002-06-12
5
383 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi: how to implement a User Shortcut mapper? 1 109
select query - oracle 16 100
How to load 2 images in same column in Delphi 2 45
Tidtcpserver listening on multiports? 1 26
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

785 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