Test Server reachable BEFORE connect

The BETA tester's forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
af0815
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 24.03.2017, 12:49

Test Server reachable BEFORE connect

Postby af0815 » 25.04.2017, 07:50

Is it possible to test, if a server is reachable before the ZConnection is activated.

I looked inside the ping and pingserver, but both use FConnection, but FConnection is not created at this time. I want to use this to decide to use a buffed Dataset or to connect to a server. One goal is, the must not wait for an timeout. A ping on OS is possible, but i see only if the Server is up, not if a service is up and reachable.

I have searched around (in this forum too), but i found only entires the worked on a open Connection like reconnect and lost connection, not at 'befor connection' time.

Any hint to handle this ?

Andreas

Edit: Win10_64/Lazarus_32/ZeosTrunk/ado/MsSql

marsupilami
Gold Boarder
Gold Boarder
Posts: 591
Joined: 17.01.2011, 14:17

Re: Test Server reachable BEFORE connect

Postby marsupilami » 26.04.2017, 22:46

Hello Andreas,

Zeos doesn't provide anything to solve that problem. Mainly because Zeos is agnostic to networks and protocols and only uses client libraries. It doesn't know wether the database is working by TCP/IP, XNET air mail or smoke signals. ;) And client libraries usually only provide methods for connecting to the server.

Sayin you don't want to wait for a timeout isn't realistic - if you don't wait for a short time you don't give the other host a possibility to answer. So you always will have to live with a short timeout. What you could do is - you could try to create a tcp connection if you know the host name / ip address and port numer. Try to connect to it with a very small timeout - say 1 to 5 seconds and see wether you get a tcp connection. See if that works and if it works disconnect and do the real connection procedure.

Since your signature says, you are on MS SQL, this also might be something for you: http://stackoverflow.com/questions/4308 ... er#4308425

With best regards,

Jan

af0815
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 24.03.2017, 12:49

Re: Test Server reachable BEFORE connect

Postby af0815 » 27.04.2017, 15:02

Ok, thanks Jan,

i ask this, because i found in ZAbstractconnection

this functions
function Ping: Boolean; virtual;
function PingServer: Boolean; virtual;


This was the reason for my question. I can use a ping for tests the server too, normally if the ping is ok, the DB is also reachable. Thx for the link, but i didnt want to deal with the connection-timeout. Normally its ok, but at startup without a (ping)check, the app look like hanging.

Andreas

marsupilami
Gold Boarder
Gold Boarder
Posts: 591
Joined: 17.01.2011, 14:17

Re: Test Server reachable BEFORE connect

Postby marsupilami » 27.04.2017, 22:55

Hello Andreas,

the ping method usually just uses the functionality of the database client library to ping the server as part ot its protocol. Firebird can do that as far as I know. I am not sure about MSSQL with ADO.

With best regards,

Jan


Return to “ZeosLib 7.2 Betatest Forum”

Who is online

Users browsing this forum: No registered users and 1 guest