I've written a little monitoring script in PHP, which should monitor a virtual directory and it's active directories. Everything works fine but when the virtual directory service freezes is my ldap\_connect() not able to connect but also doesn't get an error back. So my whole script stands still. I think that the ldap\_connect function gets a timeout back (like when you try to ping an IP and it's not reachable).

That's my connect command:

```
$connection = ldap_connect($hostname, $port) or die("Could not connect to {$hostname});

```

And I haven't found something in the manual for ldap\_connect() ([manual](http://php.net/manual/de/function.ldap-connect.php)) about a timelimit parameter in which you could define how long the function should try to connect until it aborts.

How ever I wasn't quite able to come up with a solution with `try` and `catch` or something like this. I also didn't wanted to use the `set_time_limit()` function because my script needs to be run until the end.

I appreciate every help :)
Thanks and greetings
Tim