您好,欢迎访问一九零五行业门户网

这个错误怎么解决啊 主机放弃一个已建立的连接 Warning: socket_read() : unable to read from socket

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 >>; var $recvflag = 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 socket,$msg,strlen($msg))){ //echo $buffer; } $result = socket_read($this->socket,1024); $this->response = $result; if($this->debug == 1){ //printf(%s $msg
,$this->sendflag); //printf(%s $result
,$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  好像没错误
//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= 
socket_last_error返回的错误号是多少? socket_last_error  好像没错误
//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= 
你接收时需要打循环的么?1k就能收完?
另外,程序比网络快,你发完就直接收,那边可能还没来得及发呢,你的read可能一下子就跳过了,执行了close()
最后要说的是,你了解socket和通信机制么?
如果已经做过相关工作,可以忽略这个问题
如果完全新手,还是要花时间看看socket相关资料,光错误类型就几十个,而且几乎每次都发生的“错误”都有两三个,socket编程很多时候要通过判断错误来确认数据状态的,因为有些非致命“错误”是必然发生的,是传输结束的标志
tcp,能用curl就用curl吧。
很明显,你应该是已经将socket close了,还继续向socket 读取数据和发送数据。
其它类似信息

推荐信息