php - How to lookup IP address and port from domain name redirect -


i have got php based webpage pulling playing info shoutcast server , displaying end users. using server ip address , port.

our shoutcast host reserves right change our server @ time, , officially gives domain name connect to, eg 123.myshoutcastexample.com http redirects lattest ip address , port number.

can 1 let me how find destination ip , port given subdomain using php? (assuming it's possible).

many in advance, phil.

i don't know how shoutcast server redirects, assuming uses standard http redirects get_headers() function can used info:

$url = 'http://www.google.com';  print_r(get_headers($url, 1)); 

this results in following being displayed (for me):

array (     [0] => http/1.0 302 found     [cache-control] => array         (             [0] => private             [1] => private, max-age=0         )      [content-type] => array         (             [0] => text/html; charset=utf-8             [1] => text/html; charset=iso-8859-1         )      [location] => http://www.google.co.uk/?gfe_rd=cr&ei=jtl-vd3covrj8web5kry     [content-length] => 259      [1] => http/1.0 200 ok  ... ) 

the top level elements of array numeric keys ([0] , [1]) http status codes (the first 302 redirect got original url, second successful request redirect url). final destination can found in [location] element - in case redirect http://www.google.co.uk/?gfe_rd=cr&ei=jtl-vd3covrj8web5kry.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -