I'm using file() to get the contents of an XML file from a remote server. The problem is, if the server is down or the user enters the wrong username for the remote server, the script just hangs, without displaying any errors. I've tried using ini_set('default_socket_timeout', 8);
before launching the script but it doesn't have any effect (probably because I don't have the right permissions). Is there any other way I can set a timeout for the remote server, then return an error if the time is exceeded?