PHP Websocket和Wamp Server出错
发布时间:2020-12-13 17:45:22 所属栏目:PHP教程 来源:网络整理
导读:我对这个Websockets真的很新,我正在尝试连接这个websocket: phpwebsocket和WAMP服务器,首先,在我的httpd.conf中我写了听9300,如果我去localhost:9300它工作正常,但是当我去控制台写道: php -q C:wampwwwdemosserver.php 我收到了这个错误: 这是serve
我对这个Websockets真的很新,我正在尝试连接这个websocket:
phpwebsocket和WAMP服务器,首先,在我的httpd.conf中我写了听9300,如果我去localhost:9300它工作正常,但是当我去控制台写道:
php -q C:wampwwwdemosserver.php 我收到了这个错误: 这是server.php的代码: <?php set_time_limit(0); require 'class.PHPWebSocket.php'; function wsOnMessage($clientID,$message,$messageLength,$binary) { global $Server; $ip = long2ip( $Server->wsClients[$clientID][6] ); if ($messageLength == 0) { $Server->wsClose($clientID); return; } if ( sizeof($Server->wsClients) == 1 ) $Server->wsSend($clientID,"There isn't anyone else in the room,but I'll still listen to you. --Your Trusty Server"); else foreach ( $Server->wsClients as $id => $client ) if ( $id != $clientID ) $Server->wsSend($id,"Visitor $clientID ($ip) said "$message""); } function wsOnOpen($clientID) { global $Server; $ip = long2ip( $Server->wsClients[$clientID][6] ); $Server->log( "$ip ($clientID) has connected." ); foreach ( $Server->wsClients as $id => $client ) if ( $id != $clientID ) $Server->wsSend($id,"Visitor $clientID ($ip) has joined the room."); } function wsOnClose($clientID,$status) { global $Server; $ip = long2ip( $Server->wsClients[$clientID][6] ); $Server->log( "$ip ($clientID) has disconnected." ); foreach ( $Server->wsClients as $id => $client ) $Server->wsSend($id,"Visitor $clientID ($ip) has left the room."); } $Server = new PHPWebSocket(); $Server->bind('message','wsOnMessage'); $Server->bind('open','wsOnOpen'); $Server->bind('close','wsOnClose'); $Server->wsStartServer('localhost',9300); ?> 谢谢. 哦,我的扩展: ;extension=php_bz2.dll extension=php_curl.dll ;extension=php_dba.dll extension=php_mbstring.dll ;extension=php_exif.dll ;extension=php_fileinfo.dll extension=php_gd2.dll ;extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_intl.dll ;extension=php_imap.dll ;extension=php_interbase.dll ;extension=php_ldap.dll ;extension=php_ming.dll ;extension=php_mssql.dll extension=php_mysql.dll extension=php_mysqli.dll ;extension=php_oci8.dll ;extension=php_oci8_11g.dll extension=php_openssl.dll ;extension=php_pdo_firebird.dll ;extension=php_pdo_mssql.dll extension=php_pdo_mysql.dll ;extension=php_pdo_oci.dll ;extension=php_pdo_odbc.dll ;extension=php_pdo_pgsql.dll extension=php_pdo_sqlite.dll ;extension=php_pgsql.dll ;extension=php_phar.dll ;extension=php_pspell.dll ;extension=php_shmop.dll ;extension=php_snmp.dll ;extension=php_soap.dll extension=php_sockets.dll ;extension=php_sqlite.dll ;extension=php_sqlite3.dll ;extension=php_sybase_ct.dll ;extension=php_tidy.dll ;extension=php_xmlrpc.dll ;extension=php_xsl.dll ;extension=php_zip.dll 而且,php -me的输出 解决方法
在WAMP Server中,如果从命令行运行,则使用的是PHP CLI.
PHP CLI使用与php在apache中运行时使用的php.ini文件不同的文件. Edit c:wampbinphpphp5.x.yphp.ini 并取消注释php_sockets扩展行以及运行PHP CLI时可能需要的任何其他扩展. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |