2

I want to connect to the URL http://example.net using curl, but I need to connect with server with IP adress 192.0.43.10. How I can say to curl which IP adress it must use?

phihag
  • 278,196
  • 72
  • 453
  • 469
Leonid
  • 55
  • 1
  • 2
  • 6
  • Correct me, you want to get an IP address by a hostname? Maybe gethostbyname() help you? – Empty Jun 18 '11 at 19:01
  • I took the liberty of replacing test.com with example.net according to RFC 2606. Feel free to revert if that's not what you intended. – phihag Jun 18 '11 at 19:03
  • I don't want to get an IP adress by a hostname. I want to use IP adress without editing hosts file. – Leonid Jun 18 '11 at 19:19

2 Answers2

3
$c = curl_init('http://192.0.43.10/u/r/l');
curl_setopt($c, CURLOPT_HTTPHEADER, array('Host: example.net'));
curl_exec($c);
phihag
  • 278,196
  • 72
  • 453
  • 469
0

Try the snoopy library is much easier.

yannis
  • 694
  • 11
  • 17