当前位置: 首页>>代码示例>>PHP>>正文


PHP Server::listen方法代码示例

本文整理汇总了PHP中Server::listen方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::listen方法的具体用法?PHP Server::listen怎么用?PHP Server::listen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server的用法示例。


在下文中一共展示了Server::listen方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testServerAcceptClient

 public function testServerAcceptClient()
 {
     self::$server->onConnectPeer(function (Peer $peer) {
         self::$peer_accepted++;
     });
     self::$server->listen();
 }
开发者ID:maestroprog,项目名称:esockets-php,代码行数:7,代码来源:TestEsocketsLinear.php

示例2: testListen_shouldDieIfAttemptsLimit

 public function testListen_shouldDieIfAttemptsLimit()
 {
     $server = new Server($this->createMockStore([[], [], ['test']]));
     $server->setDelay(0.1);
     $server->setAttemptsLimit(2);
     $events = $server->listen(time());
     $this->assertEquals([], $events, 'Завершение работы при достижении attemptsLimit');
 }
开发者ID:bashka,项目名称:bricks_http_realtimeserver_longpolling,代码行数:8,代码来源:ServerTest.php

示例3: Server

 * Copyright (c) sk89q <http://sk89q.therisenrealm.com>
 * Licensed under the GNU General Public License v3
*/
require 'config.php';
require 'server.php';
require 'shoutcast.php';
require 'audiosource.php';
require 'http.php';
set_time_limit(0);
$Server = new Server();
$AudioSource = new AudioSource();
$AudioSource->bitrate = $CONFIG['bitrate'];
$AudioSource->encoder = $CONFIG['encoder_path'];
$AudioSource->metadata_interval = $CONFIG['metadata_interval'];
$AudioSource->populate_playlist($CONFIG['music_dir']);
$AudioSource->open_next_file();
$Shoutcast = new Shoutcast();
$Shoutcast->server =& $Server;
$Shoutcast->source =& $AudioSource;
$Shoutcast->metadata_interval = $CONFIG['metadata_interval'];
$Shoutcast->server_name = $CONFIG['server_name'];
$Shoutcast->server_genre = $CONFIG['server_genre'];
$Shoutcast->server_url = $CONFIG['server_url'];
$Shoutcast->server_public = $CONFIG['server_public'];
$Shoutcast->hook_to_server();
$HTTP = new HTTP();
$HTTP->server =& $Server;
$HTTP->shoutcast =& $Shoutcast;
$HTTP->hook_to_server();
$Server->listen();
开发者ID:sk89q,项目名称:PHP-Shoutcast-Server,代码行数:30,代码来源:run.php

示例4: trim

            $address = trim(array_shift($args));
            break;
        case "-d":
            $document_root = trim(array_shift($args));
            break;
        case "--help":
            $help = true;
            break;
        case "--rewrite":
            $rewrite = true;
            break;
    }
}
if ($help) {
    print "Usage: {$script} [-p port] [-h host] [-d document_root] [--rewrite] [--help]\n";
    print "\nCurrent settings:\n";
    print "* Host          - {$address}\n";
    print "* Port          - {$port}\n";
    print "* Document Root - {$document_root}\n";
    print "* Rewrite Rule  - " . ($rewrite ? "On" : "Off") . "\n";
    exit;
}
// Strip any trailing slash from the document root
$document_root = preg_replace("!^(.*)/\$!", "\$1", $document_root);
$server = new Server($address, $port);
$server->document_root = $document_root;
if ($rewrite) {
    $server->handler_options["rewrite"] = true;
}
$server->listen();
开发者ID:jon9872,项目名称:zend-framework,代码行数:30,代码来源:server-start.php

示例5: die

<?php

include './config.php';
if ($argc != 3) {
    die("Usage: {$argv[0]} host port\n");
}
$myServer = new Server($argv[1], $argv[2]);
echo $myServer->showStatus();
$myServer->startUp();
echo $myServer->showStatus();
while (($string = $myServer->listen()) !== false) {
    echo getTimestamp() . " Got string of '{$string}'\n";
}
开发者ID:robertkeizer,项目名称:php-udp,代码行数:13,代码来源:server.php

示例6: doWork

class Server extends \FastD\Swoole\Server\Tcp
{
    /**
     * @param swoole_server $server
     * @param $fd
     * @param $data
     * @param $from_id
     * @return mixed
     */
    public function doWork(swoole_server $server, $fd, $data, $from_id)
    {
        return 'hello server1';
    }
}
class Server2 extends \FastD\Swoole\Server\Tcp
{
    /**
     * @param swoole_server $server
     * @param $fd
     * @param $data
     * @param $from_id
     * @return mixed
     */
    public function doWork(swoole_server $server, $fd, $data, $from_id)
    {
        return 'hello server2';
    }
}
$server = new Server('tcp://127.0.0.1:9527');
$server->listen(new Server2('tcp://127.0.0.1:9528'));
$server->start();
开发者ID:JanHuang,项目名称:swoole,代码行数:31,代码来源:multi_port_server.php


注:本文中的Server::listen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。