| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> php >> yong PHP de Socket jian li zi ji de liao tian shi fu wu qi

yong PHP de Socket jian li zi ji de liao tian shi fu wu qi

2008-12-19 08:07:43 编辑來源:互联网 评论
 
 
 
本文为【用PHP的Socket建立自己的聊天室服务器】的拼音翻译版
  <?PHP
  /**
  * patServer
  * PHP socket server base class
  * Events that can be handled:
  * * onStart
  * * onConnect
  * * onConnectionRefused
  * * onClose
  * * onShutdown
  * * onReceiveData
  *
  * @version 1.1
  * @author Stephan Schmidt <schst@php-tools.de>
  * @package patServer
  */
  class patServer{
  /**
  * information about the project
  * @var array $systemVars
  */
  var $systemVars = array(
   "appName" => "patServer",
   "appVersion" => "1.1",
   "author" => array("Stephan Schmidt <schst@php-tools.de>", )
   );
  /**
  * port to listen
  * @var integer $port
  */
   var $port = 10000;
  /**
  * domain to bind to
  * @var string $domain
  */
   var $domain = "localhost";
  /**
  * maximum amount of clients
  * @var integer $maxClients
  */
   var $maxClients = -1;
  /**
  * buffer size for socket_read
  * @var integer $readBufferSize
  */
   var $readBufferSize = 128;
  /**
  * end character for socket_read
  * @var integer $readEndCharacter
  */
   var $readEndCharacter = "\n";
  /**
  * maximum of backlog in queue
  * @var integer $maxQueue
  */
   var $maxQueue = 500;
  /**
  * debug mode
  * @var boolean $debug
  */
   var $debug = true;
  /**
  * debug mode
  * @var string $debugMode
  */
   var $debugMode = "text";
  /**
  * debug destination (filename or stdout)
  * @var string $debugDest
  */
   var $debugDest = "stdout";
  /**
  * empty array, used for socket_select
  * @var array $null
  */
   var $null = array();
  /**
  * all file descriptors are stored here
  * @var array $clientFD
  */
   var $clientFD = array();
  /**
  * needed to store client information
  * @var array $clientInfo
  */
   var $clientInfo = array();
  /**
  * needed to store server information
  * @var array $serverInfo
  */
   var $serverInfo = array();
  /**
  * amount of clients
  * @var integer $clients
  */
   var $clients = 0;
  /**
  * create a new socket server
  *
  * @access public
  * @param string $domain domain to bind to
  * @param integer $port port to listen to
  */
  function patServer( $domain = "localhost", $port = 10000 ){
   $this->domain = $domain;
   $this->port = $port;
   $this->serverInfo["domain"] = $domain;
   $this->serverInfo["port"] = $port;
   $this->serverInfo["servername"] = $this->systemVars["appName"];
   $this->serverInfo["serverversion"] = $this->systemVars["appVersion"];
   set_time_limit( 0 );
  }
  /**
  * set maximum amount of simultaneous connections
  *
  * @access public
  * @param int $maxClients
  */
  function setMaxClients( $maxClients ){
   $this->maxClients = $maxClients;
  }
  /**
  * set debug mode
  *
  * @access public
  * @param mixed $debug [text|htmlfalse]
  * @param string $dest destination of debug message (stdout to output or filename if log should be written)
  */
  function setDebugMode( $debug, $dest = "stdout" ){
   if( $debug === false ){
   $this->debug = false;
   return true;
   }
   $this->debug = true;
   $this->debugMode = $debug;
   $this->debugDest = $dest;
  }
  /**
  * start the server
  *
  * @access public
  * @param int $maxClients
  */
  function start(){
   $this->initFD = @socket_create( AF_INET, SOCK_STREAM, 0 );
   if( !$this->initFD )
   die( "patServer: Could not create socket." );
   // adress may be reused
   socket_setopt( $this->initFD, SOL_SOCKET, SO_REUSEADDR, 1 );
   // bind the socket
   if(!@socket_bind( $this->initFD, $this->domain, $this->port ) ){
   @socket_close( $this->initFD );
   die( "patServer: Could not bind socket to ".$this->domain." on port ".$this->port." ( ".$this->getLastSocketError( $this->initFd )." )." );
   }
   // listen on selected port
   if(!@socket_listen( $this->initFD, $this->maxQueue ) )
   die( "patServer: Could not listen ( ".$this->getLastSocketError( $this->initFd )." )." );
   $this->sendDebugMessage( "Listening on port ".$this->port.". Server started at ".date( "H:i:s", time() ) );
   // this allows the shutdown function to check whether the server is already shut down
   $GLOBALS["_patServerStatus"] = "running";
   // this ensures that the server will be sutdown correctly
   register_shutdown_function( array( $this, "shutdown" ) );
   if( method_exists( $this, "onStart" ) )
   $this->onStart();
   $this->serverInfo["started"] = time();
   $this->serverInfo["status"] = "running";
   while( true ){
   $readFDs = array();
   array_push( $readFDs, $this->initFD );
   // fetch all clients that are awaiting connections
   for( $i = 0; $i < count( $this->clientFD ); $i++ )
   if( isset( $this->clientFD[$i] ) )
   array_push( $readFDs, $this->clientFD[$i] );
   // block and wait for data or new connection
   $ready = @socket_select( $readFDs, $this->null, $this->null, NULL );
   if( $ready === false ){
   $this->sendDebugMessage( "socket_select failed." );
   $this->shutdown();
   }
   // check for new connection
   if( in_array( $this->initFD, $readFDs ) ){
   $newClient = $this->acceptConnection( $this->initFD );
   // check for maximum amount of connections
   if( $this->maxClients > 0 ){
   if( $this->clients > $this->maxClients ){
   $this->sendDebugMessage( "Too many connections." );
   if( method_exists( $this, "onConnectionRefused" ) )
   $this->onConnectionRefused( $newClient );
   $this->closeConnection( $newClient );
   }
   }
   if( --$ready <= 0 )
   continue;
   }
   // check all clients for incoming data
   for( $i = 0; $i < count( $this->clientFD ); $i++ ){
   if( !isset( $this->clientFD[$i] ) )
   continue;
   if( in_array( $this->clientFD[$i], $readFDs ) ){
   $data = $this->readFromSocket( $i );
   // empty data => connection was closed
   if( !$data ){
   $this->sendDebugMessage( "Connection closed by peer" );
   $this->closeConnection( $i );
   }else{
   $this->sendDebugMessage( "Received ".trim( $data )." from ".$i );
   if( method_exists( $this, "onReceiveData" ) )
   $this->onReceiveData( $i, $data );
   }
   }
   }
   }
  }
  /**
  * read from a socket
  *
  * @access private
  * @param integer $clientId internal id of the client to read from
  * @return string $data data that was read
  */
  function readFromSocket( $clientId ){
   // start with empty string
   $data = "";
   // read data from socket
   while( $buf = socket_read( $this->clientFD[$clientId], $this->readBufferSize ) ){
   $data .= $buf;
   $endString = substr( $buf, - strlen( $this->readEndCharacter ) );
   if( $endString == $this->readEndCharacter )
   break;
   if( $buf == NULL )
   break;
   }
   if( $buf === false )
   $this->sendDebugMessage( "Could not read from client ".$clientId." ( ".$this->getLastSocketError( $this->clientFD[$clientId] )." )." );
   return $data;
  }
  /**
  * accept a new connection
  *
  * @access public
  * @param resource &$socket socket that received the new connection
  * @return int $clientID internal ID of the client
  */
  function acceptConnection( &$socket ){
   for( $i = 0 ; $i <= count( $this->clientFD ); $i++ ){
   if( !isset( $this->clientFD[$i] ) || $this->clientFD[$i] == NULL ){
   $this->clientFD[$i] = socket_accept( $socket );
   socket_setopt( $this->clientFD[$i], SOL_SOCKET, SO_REUSEADDR, 1 );
   $peer_host = "";
   $peer_port = "";
   socket_getpeername( $this->clientFD[$i], $peer_host, $peer_port );
   $this->clientInfo[$i] = array(
   "host" => $peer_host,
   "port" => $peer_port,
   "connectOn" => time()
   );
   $this->clients++;
   $this->sendDebugMessage( "New connection ( ".$i." ) from ".$peer_host." on port ".$peer_port );
   if( method_exists( $this, "onConnect" ) )
   $this->onConnect( $i );
   return $i;
   }
   }
  }
  /**
  * check, whether a client is still connected
  *
  * @access public
  * @param integer $id client id
  * @return boolean $connected true if client is connected, false otherwise
  */
  function isConnected( $id ){
   if( !isset( $this->clientFD[$id] ) )
   return false;
   return true;
  }
  /**
  * close connection to a client
  *
  * @access public
  * @param int $clientID internal ID of the client
  */
  function closeConnection( $id ){
   if( !isset( $this->clientFD[$id] ) )
   return false;
   if( method_exists( $this, "onClose" ) )
   $this->onClose( $id );
   $this->sendDebugMessage( "Closed connection ( ".$id." ) from ".$this->clientInfo[$id]["host"]." on port ".$this->clientInfo[$id]["port"] );
   @socket_close( $this->clientFD[$id] );
   $this->clientFD[$id] = NULL;
   unset( $this->clientInfo[$id] );
   $this->clients--;
  }
  /**
  * shutdown server
  *
  * @access public
  */
  function shutDown(){
   if( $GLOBALS["_patServerStatus"] != "running" )
   exit;
   $GLOBALS["_patServerStatus"] = "stopped";
   if( method_exists( $this, "onShutdown" ) )
   $this->onShutdown();
   $maxFD = count( $this->clientFD );
   for( $i = 0; $i < $maxFD; $i++ )
   $this->closeConnection( $i );
   @socket_close( $this->initFD );
   $this->sendDebugMessage( "Shutdown server." );
   exit;
  }
  /**
  * get current amount of clients
  *
  * @access public
  * @return int $clients amount of clients
  */
  function getClients(){
   return $this->clients;
  }
  /**
  * send data to a client
  *
  * @access public
  * @param int $clientId ID of the client
  * @param string $data data to send
  * @param boolean $debugData flag to indicate whether data that is written to socket should also be sent as debug message
  */
  function sendData( $clientId, $data, $debugData = true ){
   if( !isset( $this->clientFD[$clientId] ) || $this->clientFD[$clientId] == NULL )
   return false;
   if( $debugData )
   $this->sendDebugMessage( "sending: \"" . $data . "\" to: $clientId" );
   if(!@socket_write( $this->clientFD[$clientId], $data ) )
   $this->sendDebugMessage( "Could not write '".$data."' client ".$clientId." ( ".$this->getLastSocketError( $this->clientFD[$clientId] )." )." );
  }
  /**
  * send data to all clients
  *
  * @access public
  * @param string $data data to send
  * @param array $exclude client ids to exclude
  */
  function broadcastData( $data, $exclude = array(), $debugData = true ){
   if( !empty( $exclude ) && !is_array( $exclude ) )
   $exclude = array( $exclude );
   for( $i = 0; $i < count( $this->clientFD ); $i++ ){
   if( isset( $this->clientFD[$i] ) && $this->clientFD[$i] != NULL && !in_array( $i, $exclude ) ){
   if( $debugData )
   $this->sendDebugMessage( "sending: \"" . $data . "\" to: $i" );
   if(!@socket_write( $this->clientFD[$i], $data ) )
   $this->sendDebugMessage( "Could not write '".$data."' client ".$i." ( ".$this->getLastSocketError( $this->clientFD[$i] )." )." );
   }
   }
  }
  /**
  * get current information about a client
  *
  * @access public
  * @param int $clientId ID of the client
  * @return array $info information about the client
  */
  function getClientInfo( $clientId ){
   if( !isset( $this->clientFD[$clientId] ) || $this->clientFD[$clientId] == NULL )
   return false;
   return $this->clientInfo[$clientId];
  }
  /**
  * send a debug message
  *
  * @access private
  * @param string $msg message to debug
  */
  function sendDebugMessage( $msg ){
   if( !$this->debug )
   return false;
   $msg = date( "Y-m-d H:i:s", time() ) . " " . $msg;
   switch( $this->debugMode ){
   case "text":
   $msg = $msg."\n";
   break;
   case "html":
   $msg = htmlspecialchars( $msg ) . "<br />\n";
   break;
   }
   if( $this->debugDest == "stdout" || empty( $this->debugDest ) ){
   echo $msg;
   flush();
   return true;
   }
   error_log( $msg, 3, $this->debugDest );
   return true;
  }
  /**
  * return string for last socket error
  *
  * @access public
  * @return string $error last error
  */
  function getLastSocketError( &$fd ){
   $lastError = socket_last_error( $fd );
   return "msg: " . socket_strerror( $lastError ) . " / Code: ".$lastError;
  }
  function onReceiveData($ip,$data){
  $this->broadcastData( $data,array(), true );
  }
  }
  $patServer = new patServer();
  $patServer->start();
  ?>【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
<?PHP /** * patServer * PHP socket server base class * Events that can be handled: * * onStart * * onConnect * * onConnectionRefused * * onClose * * onShutdown * * onReceiveData * * @version 1.1 * @author Stephan Schmidt <[url=mailto:schst@php-tools.de]schst@php-tools.de[/url]> * @package patServer */ class patServer{ /** * information about the project * @var array $systemVars */ var $systemVars = array( "appName" => "patServer", "appVersion" => "1.1", "author" => array("Stephan Schmidt <[url=mailto:schst@php-tools.de]schst@php-tools.de[/url]>", ) ); /** * port to listen * @var integer $port */ var $port = 10000; /** * domain to bind to * @var string $domain */ var $domain = "localhost"; /** * maximum amount of clients * @var integer $maxClients */ var $maxClients = -1; /** * buffer size for socket_read * @var integer $readBufferSize */ var $readBufferSize = 128; /** * end character for socket_read * @var integer $readEndCharacter */ var $readEndCharacter = "\n"; /** * maximum of backlog in queue * @var integer $maxQueue */ var $maxQueue = 500; /** * debug mode * @var boolean $debug */ var $debug = true; /** * debug mode * @var string $debugMode */ var $debugMode = "text"; /** * debug destination (filename or stdout) * @var string $debugDest */ var $debugDest = "stdout"; /** * empty array, used for socket_select * @var array $null */ var $null = array(); /** * all file descriptors are stored here * @var array $clientFD */ var $clientFD = array(); /** * needed to store client information * @var array $clientInfo */ var $clientInfo = array(); /** * needed to store server information * @var array $serverInfo */ var $serverInfo = array(); /** * amount of clients * @var integer $clients */ var $clients = 0; /** * create a new socket server * * @access public * @param string $domain domain to bind to * @param integer $port port to listen to */ function patServer( $domain = "localhost", $port = 10000 ){ $this->domain = $domain; $this->port = $port; $this->serverInfo["domain"] = $domain; $this->serverInfo["port"] = $port; $this->serverInfo["servername"] = $this->systemVars["appName"]; $this->serverInfo["serverversion"] = $this->systemVars["appVersion"]; set_time_limit( 0 ); } /** * set maximum amount of simultaneous connections * * @access public * @param int $maxClients */ function setMaxClients( $maxClients ){ $this->maxClients = $maxClients; } /** * set debug mode * * @access public * @param mixed $debug [text|htmlfalse] * @param string $dest destination of debug message (stdout to output or filename if log should be written) */ function setDebugMode( $debug, $dest = "stdout" ){ if( $debug === false ){ $this->debug = false; return true; } $this->debug = true; $this->debugMode = $debug; $this->debugDest = $dest; } /** * start the server * * @access public * @param int $maxClients */ function start(){ $this->initFD = @socket_create( AF_INET, SOCK_STREAM, 0 ); if( !$this->initFD ) die( "patServer: Could not create socket." ); // adress may be reused socket_setopt( $this->initFD, SOL_SOCKET, SO_REUSEADDR, 1 ); // bind the socket if([url=mailto:!@socket_bind]!@socket_bind[/url]( $this->initFD, $this->domain, $this->port ) ){ @socket_close( $this->initFD ); die( "patServer: Could not bind socket to ".$this->domain." on port ".$this->port." ( ".$this->getLastSocketError( $this->initFd )." )." ); } // listen on selected port if([url=mailto:!@socket_listen]!@socket_listen[/url]( $this->initFD, $this->maxQueue ) ) die( "patServer: Could not listen ( ".$this->getLastSocketError( $this->initFd )." )." ); $this->sendDebugMessage( "Listening on port ".$this->port.". Server started at ".date( "H:i:s", time() ) ); // this allows the shutdown function to check whether the server is already shut down $GLOBALS["_patServerStatus"] = "running"; // this ensures that the server will be sutdown correctly register_shutdown_function( array( $this, "shutdown" ) ); if( method_exists( $this, "onStart" ) ) $this->onStart(); $this->serverInfo["started"] = time(); $this->serverInfo["status"] = "running"; while( true ){ $readFDs = array(); array_push( $readFDs, $this->initFD ); // fetch all clients that are awaiting connections for( $i = 0; $i < count( $this->clientFD ); $i++ ) if( isset( $this->clientFD[$i] ) ) array_push( $readFDs, $this->clientFD[$i] ); // block and wait for data or new connection $ready = @socket_select( $readFDs, $this->null, $this->null, NULL ); if( $ready === false ){ $this->sendDebugMessage( "socket_select failed." ); $this->shutdown(); } // check for new connection if( in_array( $this->initFD, $readFDs ) ){ $newClient = $this->acceptConnection( $this->initFD ); // check for maximum amount of connections if( $this->maxClients > 0 ){ if( $this->clients > $this->maxClients ){ $this->sendDebugMessage( "Too many connections." ); if( method_exists( $this, "onConnectionRefused" ) ) $this->onConnectionRefused( $newClient ); $this->closeConnection( $newClient ); } } if( --$ready <= 0 ) continue; } // check all clients for incoming data for( $i = 0; $i < count( $this->clientFD ); $i++ ){ if( !isset( $this->clientFD[$i] ) ) continue; if( in_array( $this->clientFD[$i], $readFDs ) ){ $data = $this->readFromSocket( $i ); // empty data => connection was closed if( !$data ){ $this->sendDebugMessage( "Connection closed by peer" ); $this->closeConnection( $i ); }else{ $this->sendDebugMessage( "Received ".trim( $data )." from ".$i ); if( method_exists( $this, "onReceiveData" ) ) $this->onReceiveData( $i, $data ); } } } } } /** * read from a socket * * @access private * @param integer $clientId internal id of the client to read from * @return string $data data that was read */ function readFromSocket( $clientId ){ // start with empty string $data = ""; // read data from socket while( $buf = socket_read( $this->clientFD[$clientId], $this->readBufferSize ) ){ $data .= $buf; $endString = substr( $buf, - strlen( $this->readEndCharacter ) ); if( $endString == $this->readEndCharacter ) break; if( $buf == NULL ) break; } if( $buf === false ) $this->sendDebugMessage( "Could not read from client ".$clientId." ( ".$this->getLastSocketError( $this->clientFD[$clientId] )." )." ); return $data; } /** * accept a new connection * * @access public * @param resource &$socket socket that received the new connection * @return int $clientID internal ID of the client */ function acceptConnection( &$socket ){ for( $i = 0 ; $i <= count( $this->clientFD ); $i++ ){ if( !isset( $this->clientFD[$i] ) || $this->clientFD[$i] == NULL ){ $this->clientFD[$i] = socket_accept( $socket ); socket_setopt( $this->clientFD[$i], SOL_SOCKET, SO_REUSEADDR, 1 ); $peer_host = ""; $peer_port = ""; socket_getpeername( $this->clientFD[$i], $peer_host, $peer_port ); $this->clientInfo[$i] = array( "host" => $peer_host, "port" => $peer_port, "connectOn" => time() ); $this->clients++; $this->sendDebugMessage( "New connection ( ".$i." ) from ".$peer_host." on port ".$peer_port ); if( method_exists( $this, "onConnect" ) ) $this->onConnect( $i ); return $i; } } } /** * check, whether a client is still connected * * @access public * @param integer $id client id * @return boolean $connected true if client is connected, false otherwise */ function isConnected( $id ){ if( !isset( $this->clientFD[$id] ) ) return false; return true; } /** * close connection to a client * * @access public * @param int $clientID internal ID of the client */ function closeConnection( $id ){ if( !isset( $this->clientFD[$id] ) ) return false; if( method_exists( $this, "onClose" ) ) $this->onClose( $id ); $this->sendDebugMessage( "Closed connection ( ".$id." ) from ".$this->clientInfo[$id]["host"]." on port ".$this->clientInfo[$id]["port"] ); @socket_close( $this->clientFD[$id] ); $this->clientFD[$id] = NULL; unset( $this->clientInfo[$id] ); $this->clients--; } /** * shutdown server * * @access public */ function shutDown(){ if( $GLOBALS["_patServerStatus"] != "running" ) exit; $GLOBALS["_patServerStatus"] = "stopped"; if( method_exists( $this, "onShutdown" ) ) $this->onShutdown(); $maxFD = count( $this->clientFD ); for( $i = 0; $i < $maxFD; $i++ ) $this->closeConnection( $i ); @socket_close( $this->initFD ); $this->sendDebugMessage( "Shutdown server." ); exit; } /** * get current amount of clients * * @access public * @return int $clients amount of clients */ function getClients(){ return $this->clients; } /** * send data to a client * * @access public * @param int $clientId ID of the client * @param string $data data to send * @param boolean $debugData flag to indicate whether data that is written to socket should also be sent as debug message */ function sendData( $clientId, $data, $debugData = true ){ if( !isset( $this->clientFD[$clientId] ) || $this->clientFD[$clientId] == NULL ) return false; if( $debugData ) $this->sendDebugMessage( "sending: \"" . $data . "\" to: $clientId" ); if([url=mailto:!@socket_write]!@socket_write[/url]( $this->clientFD[$clientId], $data ) ) $this->sendDebugMessage( "Could not write '".$data."' client ".$clientId." ( ".$this->getLastSocketError( $this->clientFD[$clientId] )." )." ); } /** * send data to all clients * * @access public * @param string $data data to send * @param array $exclude client ids to exclude */ function broadcastData( $data, $exclude = array(), $debugData = true ){ if( !empty( $exclude ) && !is_array( $exclude ) ) $exclude = array( $exclude ); for( $i = 0; $i < count( $this->clientFD ); $i++ ){ if( isset( $this->clientFD[$i] ) && $this->clientFD[$i] != NULL && !in_array( $i, $exclude ) ){ if( $debugData ) $this->sendDebugMessage( "sending: \"" . $data . "\" to: $i" ); if([url=mailto:!@socket_write]!@socket_write[/url]( $this->clientFD[$i], $data ) ) $this->sendDebugMessage( "Could not write '".$data."' client ".$i." ( ".$this->getLastSocketError( $this->clientFD[$i] )." )." ); } } } /** * get current information about a client * * @access public * @param int $clientId ID of the client * @return array $info information about the client */ function getClientInfo( $clientId ){ if( !isset( $this->clientFD[$clientId] ) || $this->clientFD[$clientId] == NULL ) return false; return $this->clientInfo[$clientId]; } /** * send a debug message * * @access private * @param string $msg message to debug */ function sendDebugMessage( $msg ){ if( !$this->debug ) return false; $msg = date( "Y-m-d H:i:s", time() ) . " " . $msg; switch( $this->debugMode ){ case "text": $msg = $msg."\n"; break; case "html": $msg = htmlspecialchars( $msg ) . "<br />\n"; break; } if( $this->debugDest == "stdout" || empty( $this->debugDest ) ){ echo $msg; flush(); return true; } error_log( $msg, 3, $this->debugDest ); return true; } /** * return string for last socket error * * @access public * @return string $error last error */ function getLastSocketError( &$fd ){ $lastError = socket_last_error( $fd ); return "msg: " . socket_strerror( $lastError ) . " / Code: ".$lastError; } function onReceiveData($ip,$data){ $this->broadcastData( $data,array(), true ); } } $patServer = new patServer(); $patServer->start(); ?>
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
可爱小魔女
夏日小桃红
琦吖囡半熟乖巧清新写真
天使的微笑
痞子的甘南日记
疑是银河落九天
雪域坝上四——纯美色
冬日恋歌——西城杨柳弄轻柔
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有