Memory App
Programming
 




Valid IP


<?php
    $ip   = gethostbyname('www.example.com');
    $long = ip2long($ip);

    if ($long == -1 || $long === FALSE) { // look here
        echo 'Invalid IP, please try again';
    } else {
        echo $ip; // 192.0.34.166
        echo $long; // -1073732954
    }
(1/5)

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);
(2/5)

socket_set_timeout()

Set timeout period on a stream (alias of the stream_set_timeout)

<?php
    stream_set_timeout($fp, 2);
(3/5)

getservbyname()

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

ip2long()

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

Questions



Top Reference > Programming