Syntax: int fsockopen (string hostname, int port, int [errno], string [errstr], int [timeout]);
return value: Integer
Function type: Network system content Description: At present PHP network function Fsockopen provides two Socket data flow interface, respectively for the Internet use of af_inet and Unix Af_unix. When used in the Internet situation, the parameters hostname and port respectively represent the URL and port number. In the UNIX scenario, the Ipc,hostname parameter is represented to the socket path, and port is configured to 0. The timeout option that can be omitted indicates how long it has been interrupted without a connection. After using this function, a file pointer is returned for use by the file function, including fgets (), FGETSS (), fputs (), fclose (), and feof (). Parameters errno and Errstr can also be omitted, mainly as error handling use. With this function, the shelve mode (blocking mode) is used, and the set_socket_blocking () can be converted to no-hold mode.
PHP Network function Fsockopen Use example, this example is used to simulate the HTTP connection.
- PHP
- $ FP = Fsockopen ("Php.wilson.gs", & $errno, & $errstr, 10);
- if (! $fp) {
- echo "$errstr ($errno) < BR > n ";
- } else {
- Fputs ($fp, "get/http/1.0nhost:php.wilson.gsnn");
- while (!feof ($fp)) {
- Echo fgets ($FP, 128);
- }
- Fclose ($FP);
- }
- ?>
Using the above PHP network function Fsockopen example, readers are not already able to grasp the basic function of the use of it?
http://www.bkjia.com/PHPjc/446295.html www.bkjia.com true http://www.bkjia.com/PHPjc/446295.html techarticle syntax: int fsockopen (string hostname, int port, int [errno], string [errstr], int [timeout]), return value: Type of integer function: Description of network system content: current P HP Network Functions ...