php fsockopen
1 private function request($path, $post, $port = 80, $timeout = 50) 2 { 3 $socket = fsockopen($this->_server, $port, $errno, $errstr, $timeout); 4 if (!$socket){ 5 return false; 6 } 7 fwrite($socket, "POST $path HTTP/1.0\r\n"); 8 fwrite($socket, "User-Agent: Socket Example\r\n"); 9 fwrite($socket, "HOST: $this->_server\r\n"); 10 fwrite($socket, "Content-type: application/x-www-form-urlencoded\r\n"); 11 fwrite($socket, "Content-length: " . (strlen($post) + 8) . "\r\n"); 12 fwrite($socket, "Accept:*/*\r\n"); 13 fwrite($socket, "\r\n"); 14 fwrite($socket, "params=$post\r\n"); 15 fwrite($socket, "\r\n"); 16 $header = ""; 17 while ($str = trim(fgets($socket, 4096))) { 18 $header .= $str; 19 } 20 $data = ""; 21 while (!feof($socket)) { 22 $data .= fgets($socket, 4096); 23 } 24 return $data; 25 }