I have a small application that I created to analyze network connectivity. It starts from the browser and connects to the local PHP / Apache server. He then asks PHP to send the ping packet through the raw socket. The problem is that if the host I'm trying to ping is not alive or will not respond to requests, we will never receive a response from the server.
I will leave the socket request until apache is restarted. Lately, I get mixed results from my application and I blame apache using too many sockets. I have currently set an AJAX call timeout, and I was pleased with that. But I really need to get PHP to timeout so that I don't have 500,000 sockets open to an inaccessible host.
Code example:
$sockconn = @socket_connect($socket, $target, null); if(!$sockconn) { $raw['error'] = socket_strerror(socket_last_error()); $raw['status'] = false; return $raw; }
This is a function that will not timeout. I need to get it before the timeout. Also a PHP script runtime does NOT affect sockets.
I dont know.
Axel latvala
source share