Example #1
0
 static function bindAndListen($ip, $port, $event)
 {
     self::$event = $event;
     self::$maxWorkerNameLength = PHPServer::getMaxWorkerNameLength();
     // telnet控制server的socket
     $error_no = 0;
     $error_msg = '';
     self::$bindSocket = stream_socket_server("tcp://{$ip}:{$port}", $error_no, $error_msg);
     if (!self::$bindSocket) {
         return false;
     }
     // telnet添加accept事件
     $event->add(self::$bindSocket, BaseEvent::EV_ACCEPT, array('Telnet', 'acceptConnection'));
     return true;
 }