public function gateway($url,$time_out = "60") { $urlinfo = parse_url($url); $errno = ""; $errstr = ""; if($urlinfo['scheme']=="https"){ $transports = "ssl://"; $urlinfo['port'] = "443"; }else{ $transports = "tcp://"; $urlinfo['port'] = "803"; } if(isset($urlinfo['query'])){ $query = '?'.$urlinfo['query']; }else{ $query = ''; } $urlinfo['path'] = $urlinfo['path'].$query; $fp = @fsockopen($transports.$urlinfo['host'],$urlinfo['port'],$errno,$errstr,$time_out); if(!$fp){ die("ERROR: $errno - $errstr<br/>\n"); }else{ fputs($fp,"GET ".$urlinfo['path']." HTTP/1.1\r\n"); fputs($fp,"Host: ".$urlinfo['host']."\r\n"); fputs($fp,"Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp,"Content-length: ".strlen($urlinfo['query'])."\r\n"); fputs($fp,"Connection: close\r\n\r\n"); fputs($fp,$urlinfo['query']."\r\n\r\n"); fclose($fp); } }
php fsockopen多线程实现
最新推荐文章于 2024-03-09 21:11:15 发布