[unixODBC-support] Please Help Me. (If you dont help me, I will be fired by my boss.)

Martin J. Evans martin.evans at easysoft.com
Fri Oct 21 09:02:32 BST 2005


This is the way tcp/ip and connect() works. In the case of the IP which exists
but is not listening on the port that machine returns a message indicating
connection is refused. In the case of the IP which does not exist your system
will get no message back and will eventually time out (usually this timeout is
built into your kernel - sometimes you can change it without rebuilding your
kernel but it will affect all tcp/ip).

Some ODBC drivers don't support a SQL_ATTR_CONNECTION_TIMEOUT or
SQL_ATTR_LOGIN_TIMEOUT but in any case SQL_ATTR_CONNECTION_TIMEOUT is not
relevant to your scenario. You can either try any of the following but they are
all problematic:

o set an alarm to go off after the time you require. Depending on the how the
  driver is written this may interrupt the connect() call (of course the driver
  can a) ignore signals b) restart the connect, both of which will stop this
  working). Also, on some OSs, signals and threads don't go together very well
  i.e. which thread receives the signal?

o create a thread to connect and another thread to watch the first one. In that
  way, if your connect does not succeed after yout time, you can continue
  processing in one thread whilst the other one times out.

You could always ask the Postgres folk if they implement SQL_ATTR_LOGIN_TIMEOUT.

Martin
--
Martin J. Evans
Easysoft Ltd, UK
Development

On 21-Oct-2005 lengwuqing at sohu.com wrote:

Hi,All:
     I work on Solaris 8 and Solaris 9, the database is PostgreSql 7.4, the
unixODBC is 2.2.11.
     I copied the ODBC test program from unixODBC.org, and set the
Login-Timeout and connect to my database.
     If the ip of the target database is an existent IP but not database, the
SQLConnect function return a false value immediately; While the ip of the
target database isnot an existent IP, the SQLConnect ignore my timeout setting
and always hold for 225 sendonds<The actual value is a fixed as 225.>.
     Could you all tell me how I can ctronol the timeout in my this case?
Thanks.
lengwuqing



More information about the unixODBC-support mailing list