ExpertRefresh

Streams / Network  

1) Get ip by host






<?php $ip = gethostbyname('www.example.com'); $long = ip2long($ip); if ($long == -1 || $long === FALSE) { echo 'Invalid IP, please try again'; } else { echo $ip; // 192.0.34.166 echo $long; // -1073732954 }

fsockopen()

Open Internet or Unix domain socket connection. Use the fsockopen function to open a socket connection for communicating with a server whose protocol is not supported by PHP <?php fsockopen("www.example.com", 80, $errno, $errstr, 30);

socket_set_timeout()

Set timeout period on a stream (alias of the stream_set_timeout) <?php stream_set_timeout($fp, 2);

getservbyname()

Get port number associated with an Internet service and protocol -- int getservbyname ( string $service , string $protocol )

ip2long()

Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address


References