21,886
社区成员
发帖
与我相关
我的任务
分享
while(true){
$changed = $this->sockets;
$write=NULL;
$except=NULL;
socket_select($changed,$write,$except,NULL);
foreach($changed as $socket){
if($socket==$this->master){
$client=socket_accept($this->master);
if($client<0){ $this->log("socket_accept() failed"); continue; }
else{ $this->connect($client); }
}
else{
/*if(1=1){
$user = $this->getuserbysocket($socket);
if(!$user->handshake){ $this->dohandshake($user,$buffer);}
$this->process($user,$this->unwrap($buffer));
}*/
$bytes = @socket_recv($socket,$buffer,2048,0);
if($bytes==0){ $this->disconnect($socket); }
else{
$user = $this->getuserbysocket($socket);
if(!$user->handshake){ $this->dohandshake($user,$buffer);}
else{ $this->process($user,$this->unwrap($buffer));}
}
}
}
}