I know I can set a max execution time on an entire script.
But can I set a max execution time on a block of code? say, a function that connects to an SMTP server?
I have a script here that attempts to connect to a sequence of SMTP servers and send a message. If one of them is down, the connection will timeout. I'm using Pear Mail::factory to do it... it has a "timeout" parameter, but evidently it's useless. I looked in the source code and that parameter isn't used anywhere.
So, I have some commands that might time out. They don't throw an error, they don't die, they just hang hang hang.
I wish there was a try/catch sort of solution for this. Like, "try" to do this, but "catch" if it takes longer than 5 seconds.
What can I do?