


connect OK.
Warning: socket_write() [function.socket-write]: unable to write to socket [0]: 您的主机中的软件放弃了一个已建立的连接。 in D:\qzweb-st\mfvy1\wwwroot\mobile_ol.php on line 40
Warning: socket_read() [function.socket-read]: unable to read from socket [0]: 您的主机中的软件放弃了一个已建立的连接。 in D:\qzweb-st\mfvy1\wwwroot\mobile_ol.php on line 43
<?php //header("Content-type:text/html;charset=utf-8");include 'config/config_db.php';$conn = @mysql_connect(DB_HOST,DB_USER,DB_PASSWORD); if (!$conn){ die("连接数据库失败:" . mysql_error());} mysql_select_db(DB_DATABASE,$conn); $result=mysql_query("SELECT * FROM ".DB_PREFIX."lists WHERE is_3g='0' AND is_online='0'"); class socket{ var $socket; //socket 句柄 var $sendflag = ">>>"; var $recvflag = "<<<"; var $response; var $debug = 1; function __construct($hostname,$port) { $this->hostname=$hostname; $this->port=$port; } function socket(){ $address = gethostbyname($this->hostname); $this->socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP); $result = socket_connect($this->socket,$address,$this->port); if($this->debug == 1){ if ($result < 0) { echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "<br>"; } else{ echo "connect OK.<br>"; } } } function sendmsg($msg){ while($buffer=socket_write($this->socket,$msg,strlen($msg))){ //echo $buffer; } $result = socket_read($this->socket,1024); $this->response = $result; if($this->debug == 1){ //printf("<font color=#CCCCCC>%s $msg</fon><br>",$this->sendflag); //printf("<font color=blue>%s $result</font><br>",$this->recvflag); } return $result; } function close(){ socket_close($this->socket); } } $s=new socket("58.60.12.177",14000);while($row = mysql_fetch_array($result)){ $s->socket();$s->sendmsg("VER=1.4&CON=1&CMD=Login&SEQ=112255&UIN=".$row['qq_number']."&PS=".$row['qq_pw']."&M5=1&LG=0&LC=812822641C978097&GD=5MWX2PF3FOVGTP6B&CKE=\r\n");/*$s->sendmsg("VER=1.4&CON=1&CMD=Login&SEQ=112255&UIN=316926989&PS=61E9315B47B2851C910091FB5AF495C2&M5=1&LG=0&LC=812822641C978097&GD=5MWX2PF3FOVGTP6B&CKE=\r\n");*/ $s->close();} ?>
回复讨论(解决方案)
socket_last_error返回的错误号是多少?
socket_last_error 好像没错误 socket_last_error返回的错误号是多少? socket_last_error 好像没错误 你接收时需要打循环的么?1k就能收完? tcp,能用curl就用curl吧。 很明显,你应该是已经将socket close了,还继续向socket 读取数据和发送数据。
//echo $buffer; 返回值是 142142142 一排
40之前都对的 网页上显示出connect OK. 这个了
//printf("%s $msg
",$this->sendflag);
//printf("%s $result
",$this->recvflag);
输出
>>> VER=1.4&CON=1&CMD=Login&SEQ=112255&UIN=2810316641&PS=CA9ED0A4F6F2A06017F09D3CA53D030B&M5=1&LG=0&LC=812822641C978097&GD=5MWX2PF3FOVGTP6B&CKE=
//echo $buffer; 返回值是 142142142 一排
40之前都对的 网页上显示出connect OK. 这个了
//printf("%s $msg
",$this->sendflag);
//printf("%s $result
",$this->recvflag);
输出
>>> VER=1.4&CON=1&CMD=Login&SEQ=112255&UIN=2810316641&PS=CA9ED0A4F6F2A06017F09D3CA53D030B&M5=1&LG=0&LC=812822641C978097&GD=5MWX2PF3FOVGTP6B&CKE=
另外,程序比网络快,你发完就直接收,那边可能还没来得及发呢,你的read可能一下子就跳过了,执行了close()
最后要说的是,你了解socket和通信机制么?
如果已经做过相关工作,可以忽略这个问题
如果完全新手,还是要花时间看看socket相关资料,光错误类型就几十个,而且几乎每次都发生的“错误”都有两三个,socket编程很多时候要通过判断错误来确认数据状态的,因为有些非致命“错误”是必然发生的,是传输结束的标志

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools