喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 喜悦证交所 | 帮助

RSS 订阅当前论坛  

$5.95 Web Hosting     

上一主题 下一主题
     
标题: [问题] Socket连接第二次发送请求时获得的还是第一次的数据????  
 
eays (eays)
注册会员
Rank: 2
中级会员



UID 65358
精华 0
积分 190
帖子 174
金钱 190 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2005-8-1
来自 四川.中国
状态 离线
[广告]: 代充Paypal帐号美元
Socket连接第二次发送请求时获得的还是第一次的数据????

我的Socket类:

<?php
class Socket_Client{
var 
$SocketClient;
var 
$Host;
var 
$Port;
var 
$TimeOut;
var 
$ErrNo;
var 
$ErrStr;
var 
$SendContent '';
var 
$GetContent;
var 
$HttpPost;
var 
$HttpGet;

function 
Connect($Host $Port 80 $TimeOut 30 ){
$this->Port $Port;
$this->TimeOut $TimeOut;
$this->Host $Host;
return 
$this->SocketClient fsockopen(gethostbyname($this->Host),$this->Port,$this->ErrNo,$this->ErrStr,$this->TimeOut) or exit($this->ErrStr."--->".$this->ErrNo);
}

function 
SendPost($Posto,$PostFrom,$ContentArray){
if(!
$this->SocketClient) return 'Socket Client Not Opened.';

$flag 0;
foreach (
$ContentArray as $key=>$value) { 
    if (
$flag!=0) {
        
$this->SendContent .= "&"
        
$flag 0
    } 
    
$this->SendContent.= $key."="$this->SendContent.= urlencode($value); 
    
$flag 1
    } 

$this->HttpPost  "POST ".$Posto." HTTP/1.1rn";
$this->HttpPost .= "Host:".gethostbyname($this->Host)."rn";
$this->HttpPost .= "Referer:".$PostFrom."rn"
$this->HttpPost .= "Content-Type: application/x-www-form-urlencodedrn";
$this->HttpPost .= "Content-Length: ".strlen($this->SendContent)."rn";
$this->HttpPost .= "Connection: Closernrn";
$this->HttpPost .= $this->SendContent."rn";
return 
fputs($this->SocketClient,$this->HttpPost); 
}

function 
SendGet($Geto,$GetForm){
$this->HttpGet  "GET ".$Geto." HTTP/1.1rn"
$this->HttpGet .= "Host: ".gethostbyname($this->Host)."rn"
$this->HttpGet .= "Accept: */*rn"
$this->HttpGet .= "Referer: ".$GetForm."rn"
$this->HttpGet .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)rn"
$this->HttpGet .= "Connection: Closernrn"
return 
fputs($this->SocketClient,$this->HttpGet);
}

function 
Get(){
if(!
$this->SocketClient) return 'Socket Client Not Opened.';
while (!
feof($this->SocketClient)) {
    
$this->GetContent .= fgets($this->SocketClient,1024);
    }
return 
$this->GetContent;    
}

function 
Close(){
fclose($this->SocketClient);
}

}
?>
使用类:

$Socket = new Socket_Client();
$Socket->SendPost("/cgi-bin/nEWpAYcENTER/Domain/DomainLogin","/domainmanage/management.htm",$ContentArray);
echo $Socket->Get(); #这里返回的是第一次请求POST返回的内容.
$Socket->SendGet($GetHttpURL,"/cgi-bin/nEWpAYcENTER/Domain/DomainLogin");
echo $Socket->Get(); #这里应该是请求GET时的内容,但还是第一次POST的内容.


如果建两个Socket连接则不会有这问题.请问有没有办法用一个Socket连接搞定~~~
2006-8-29 01:24 PM#1
查看资料  访问主页  发短消息  QQ  顶部
 
eays (eays)
注册会员
Rank: 2
中级会员



UID 65358
精华 0
积分 190
帖子 174
金钱 190 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2005-8-1
来自 四川.中国
状态 离线
[广告]: 代充Paypal帐号美元
PHP代码里的斜扛不见了....\ r \ n
2006-8-29 01:25 PM#2
查看资料  访问主页  发短消息  QQ  顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.283163 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP