Though file_get_contents is not so advanced as CURL we can use it in lots of situations. In case you use file_get_contents and you need to set for how long to try to make connection you can use stream context.

First we create the stream context:
$sc = stream_context_create(array( ‘http’ => array( ‘timeout’ => 10 ) ) ); //timeout = nr of  seconds

Then we call the function:
file_get_contents($url, $sc);

So simple!
I advise you to use this, otherwise file_get_contents() could work a very long time and slow down your entire script.

file_get_contents official PHP page:
http://php.net/manual/en/function.file-get-contents.php