Home > Backend Development > PHP Tutorial > Detailed example code of fsockopen in php_PHP tutorial

Detailed example code of fsockopen in php_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-20 11:09:11
Original
908 people have browsed it

" Unable to openn"; //Output content

}
else //If successfully opened
{
fwrite($fp,"get / http/1.0rnrn"); //Write to the data stream Enter the content
stream_set_timeout($fp,2); //Set the timeout
$res=fread($fp,2000); //Read the content
$info=stream_get_meta_data($fp); /Get the data flow header
fclose($fp); ; ; >
//Create the server
$socket=stream_socket_server("tcp://0.0.0.0:8000",$errno,$errstr);
//If the creation fails
if(! $socket)
{
echo "$errstr ($errno)
n";
}
//If the creation is successful
else
{
//Accept connection
while($conn=stream_socket_accept($socket))
{
//Write data

fwrite($conn,'the local time is '.date('n/ j/y g:i a')."n");

//Close the connection

fclose($conn);

}
//Close the socket
fclose($socket);
}

//

$file="test.txt"; //Define file
$fp=fopen($file,"w"); //Open Data stream
if($fp) //If successfully opened
{
stream_set_write_buffer($fp,0); //Set buffer
fwrite($fp,$output); //Write Enter content
fclose($fp); //Close the data stream
}





http://www.bkjia.com/PHPjc/444820.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/444820.html

TechArticle

*/ $fp=fsockopen(127.0.0.1,80);//Open data stream if(!$fp )//If there is an error when opening { echo unable to openn;//Output content} else//If it is successfully opened { fwrite($fp,get / http/1.0rnrn);//To the number...


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template