fsockopen

Something faster than get_headers()

风格不统一 提交于 2019-12-04 09:33:53
问题 I'm trying to make a PHP script that will check the HTTP status of a website as fast as possible. I'm currently using get_headers() and running it in a loop of 200 random urls from mysql database. To check all 200 - it takes an average of 2m 48s. Is there anything I can do to make it (much) faster? (I know about fsockopen - It can check port 80 on 200 sites in 20s - but it's not the same as requesting the http status code because the server may responding on the port - but might not be

multi-thread, multi-curl crawler in PHP

让人想犯罪 __ 提交于 2019-12-04 04:57:47
Hi everyone once again! We need some help to develop and implement a multi-curl functionality into our crawler. We have a huge array of "links to be scanned" and we loop throw them with a Foreach. Let's use some pseudo code to understand the logic: 1) While ($links_to_be_scanned > 0). 2) Foreach ($links_to_be_scanned as $link_to_be_scanned). 3) Scan_the_link() and run some other functions. 4) Extract the new links from the xdom. 5) Push the new links into $links_to_be_scanned. 5) Push the current link into $links_already_scanned. 6) Remove the current link from $links_to_be_scanned. Now, we

Which is better approach between fsockopen and curl?

醉酒当歌 提交于 2019-12-04 00:55:57
I am creating an app for Automated Recurring Billing. Please let me know which option should I opt for sending the request to server fsockeopen curl and why one is better than another? i would recommend you curl, because of the configurable options. e.g. ssl Femi I would recommend using PHP's stream contexts with the built in functions: http://us3.php.net/manual/en/book.stream.php . Full HTTP/S functionality and integrates nicely with fopen / file_get_contents functions. You can (for example) do a POST like this: $chunk = file_get_contents("https://graph.facebook.com/oauth/access_token?client

GMail fsockopen(): SSL operation failed error with Codeigniter and XAMPP

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Error message 1: Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed Filename: libraries/Email.php Line Number: 1962 Error message 2: Message: fsockopen(): Failed to enable crypto Error message 3: Message: fsockopen(): unable to connect to >ssl://smtp.gmail.com:465 (Unknown error) php.ini: extension=php_openssl.dll -> uncommented I have tried with: openssl.cafile= C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem I have tried

php中连接tcp服务的三种方式

匿名 (未验证) 提交于 2019-12-02 22:11:45
首先需要现有一个 tcp 服务,我们使用 php中的 socket 系列函数实现 <?php //创建socket套接字 $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); //设置阻塞模式 socket_set_block($socket); //为套接字绑定ip和端口 socket_bind($socket,'127.0.0.1',3046); //监听socket socket_listen($socket,4); while(true) { //接收客户端请求 if(($msgsocket = socket_accept($socket)) !== false) { //读取请求内容 $buf = socket_read($msgsocket, 8192); echo "Received msg: $buf \n"; $str = "this is a service message"; //向连接的客户端发送数据 socket_write($msgsocket, $str,strlen($str)); //操作完之后需要关闭该连接否则 feof() 函数无法正确识别打开的句柄是否读取完成 socket_close($msgsocket); } } 连接 tcp 服务: 使用 socket 系列函数连接 <?php

Fsockopen error handling, at the moment I get warnings and page stops further content from loading

雨燕双飞 提交于 2019-12-02 21:59:46
问题 I have the following code: $open_socket = fsockopen($host,$port,$errno,$errstr,30); if(!$open_socket){ echo "$errstr ($errno)<br />".$nl; }else{ fputs($open_socket,$xml); while(!feof($open_socket)){ $line = fgets($open_socket,128); $return_xml.= $line; } fclose($open_socket); } but if there is not connection I get the following message: Warning: fsocket ...... the rest of the page is blank, basically how can I handle this where my page will continue and things will be displayed and just the

Socket connection error connecting to sandbox at www.sandbox.paypal.com

て烟熏妆下的殇ゞ 提交于 2019-12-02 14:11:42
问题 When I try connect with fsockopen : $fp = fsockopen('tls://www.sandbox.paypal.com', 443, $errno, $errstr, 30); The function shows the following errors: Warning: fsockopen() [function.fsockopen]: SSL operation failed with code 1. OpenSSL Error messages: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure in /home/puntodec/public_html/test_socket.php on (line number) Warning: fsockopen() [function.fsockopen]: Failed to enable crypto in /home/puntodec/public_html/test

Socket connection error connecting to sandbox at www.sandbox.paypal.com

拟墨画扇 提交于 2019-12-02 07:06:46
When I try connect with fsockopen : $fp = fsockopen('tls://www.sandbox.paypal.com', 443, $errno, $errstr, 30); The function shows the following errors: Warning: fsockopen() [function.fsockopen]: SSL operation failed with code 1. OpenSSL Error messages: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure in /home/puntodec/public_html/test_socket.php on (line number) Warning: fsockopen() [function.fsockopen]: Failed to enable crypto in /home/puntodec/public_html/test_socket.php on (line number) Warning: fsockopen() [function.fsockopen]: unable to connect to tls://www

Unable to find the socket transport “https”

邮差的信 提交于 2019-12-01 15:35:09
I'm using this to check for the availability of a URL: $fp = fsockopen($url, 443, $errno, $errstr); and I get this error back... Warning: fsockopen() [function.fsockopen]: unable to connect to https://example.com/soapserver.php:443 (Unable to find the socket transport "https" - did you forget to enable it when you configured PHP?) in C:\Home etc etc.... I'm using an IIS server btw,( no its not my doing! ) so I think its something to do with not having open-ssl, but I'm not sure. Can anyone help please? I did a phpinfo() and I do have ssl, but on IMAP and cURL, thats all. Any ideas? also for

How do I pass session to new socket via fsockopen?

我只是一个虾纸丫 提交于 2019-12-01 15:10:41
I need to pass the session to an asynchronous call via fsockopen in php. Can you help me pass the session to the new socket? SOLUTION: The following code works. start.php <?php session_start(); $_SESSION['var1'] = 'value1'; async_call('/async.php'); echo '<pre>'; print_r($_SESSION); echo $_COOKIE['PHPSESSID'] . "\r\n"; echo '<a href="verify.php">verify.php</a>'; function async_call($filepath) { $host = 'sandbox'; // set to your domain $sock = fsockopen($host, 80); fwrite($sock, "GET $filepath HTTP/1.1\r\n"); fwrite($sock, "Host: $host\r\n"); fwrite($sock, "Cookie: PHPSESSID=" . $_COOKIE[