?
Solved

TCP/IP waitting time

Posted on 2002-06-12
5
Medium Priority
?
388 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 800 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

719 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