Networking Functions-php PHP Networking Functions-php
When using the PHP binaries for Windows that are available from http://php.net/, the getprotobyname(), getprotobynumber(), getservbyport(), and getservbyname() may not function as anticipated under Windows 2000.
DNS resource records:
- checkdnsrr()
- getmxrr()
Domain name/IP address lookups and conversions:
- gethostbyaddr()
- gethostbyname()
- gethostbynamel()
- ip2long()
- long2ip()
Internet protocol and service information:
- getprotobynumber()
- getservbyname()
- getprotobyname()
- getservbyport()
PHP 3 debugger (warning: very broken!):
- debugger_off()
- debugger_on()
Sockets:
- fsockopen()
- pfsockopen()
- socket_get_status()
- socket_set_blocking()
- socket_set_timeout()
gethostbyaddr() gethostbyname() gethostbynamel() getmxrr()
Example:Check whether a given domain name has an MX resource record<?php $url = "http://www.php.net/"; $component = parse_url ($url); checkdnsrr ($component['host'], 'MX') or die ('No MX record exists for <i>$component[host]</i>. Did you enter the URL correctly?'); echo "MX record found for <i>$component[host]</i>"; ?>
fsockopenmixed fsockopen(string host, int port, [reference error_number], [reference error_string], [double timeout])
hostHostname or IP addressportPort numbererror_numberReference to a variable that will store the system-level error number if the function failserror_stringReference to a variable that will store the system-level error message if the function failstimeoutNumber of seconds before the connect system call times outOpens a connection to a socket.Returns:File pointer identifying the open socket; FALSE on failureDescription:fsockopen() attempts to open a network socket connection to the specified host and port. TCP connections are assumed by default, but UDP connections can be specified by placing udp:// at the start of the host .There are three optional arguments: error_number , error_string , and timeout . Both the error_number and error_string arguments must be passed as references, as in &$error_number and &$error_string. If an error occurs, these variables will contain an error code and a message. If the error number is 0, this is usually due to a problem that occurs before the socket initializes, such as an incorrect hostname.The timeout argument should contain the maximum number of seconds to wait for a connection before timing out.
<?php $host = 'www.abcxyz.com'; $port = 80; $fp = fsockopen($host, $port, &$err_no, &$err_msg, 10) or die ("Could not open a socket connection to host <i>$host</i> on port <i>$port</i>. The error message returned was '<i>$err_msg</i>'."); echo "A socket connection to host <i>$host</i> on port <i>$port</i> was successfully opened." ?>
0 Response to "Networking Functions-php"
Posting Komentar