0

它在标题中清楚地说明了这一点。我想要一种在 Wamp 2.1 附带的 apache 服务器中 运行 websocket 服务器的方法

更新

检查此页面http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/查看第 9 步,其中描述了如何运行 websocket 服务器。那是给 XAMPP 的。我想在 WAMP 中做到这一点。抱歉,如果不清楚。


日期 2

win 7上的cmd

我试图按照照片中的方式运行它,但是如您所见,我做错了。对不起,我不擅长命令行。你能告诉我运行 websocket-server 的确切方法吗


更新 3

cmd访问php.exe

又一次试验,什么也没发生。

4

2 回答 2

4

我找到了一些让 WAMP 与本教程一起工作的想法。您需要编辑 C:\wamp\bin\php\php5.3.9\php.ini 并添加一行extension=php_sockets.dll然后调用php -q C:\wamp\www\websocket\server\startDaemon.php在 cmd 中,websocket 将工作。

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Admin>php -q C:\wamp\www\websocket\server\startDaemon.php
2012-10-30 14:30:35 System: Socket Resource id #7 created.
2012-10-30 14:30:35 System: Socket bound to localhost:8000.
2012-10-30 14:30:35 System: Start listening on Socket.
2012-10-30 14:31:04 WebSocket: Resource id #8 CONNECTED!
2012-10-30 14:31:04 WebSocket: Requesting handshake...
2012-10-30 14:31:04 WebSocket: Handshaking...
2012-10-30 14:31:04 WebSocket: Done handshaking...
2012-10-30 14:31:04 WebSocket: Resource id #8 disconnected!
2012-10-30 14:31:34 WebSocket: Resource id #9 CONNECTED!
2012-10-30 14:31:34 WebSocket: Requesting handshake...
2012-10-30 14:31:34 WebSocket: Handshaking...
2012-10-30 14:31:34 WebSocket: Done handshaking...
2012-10-30 14:31:34 WebSocket: Resource id #9 disconnected!
2012-10-30 14:31:37 WebSocket: Resource id #10 CONNECTED!
2012-10-30 14:31:37 WebSocket: Requesting handshake...
2012-10-30 14:31:37 WebSocket: Handshaking...
2012-10-30 14:31:37 WebSocket: Done handshaking...
2012-10-30 14:31:37 WebSocket: Resource id #10 disconnected!
2012-10-30 14:32:23 WebSocket: Resource id #11 CONNECTED!
2012-10-30 14:32:23 WebSocket: Requesting handshake...
2012-10-30 14:32:23 WebSocket: Handshaking...
2012-10-30 14:32:23 WebSocket: Done handshaking...
2012-10-30 14:32:23 WebSocket: Resource id #11 disconnected!
2012-10-30 14:36:02 WebSocket: Resource id #12 CONNECTED!
2012-10-30 14:36:02 WebSocket: Requesting handshake...
2012-10-30 14:36:02 WebSocket: Handshaking...
2012-10-30 14:36:02 WebSocket: Done handshaking...
2012-10-30 14:36:07 WebSocket: Resource id #13 CONNECTED!
2012-10-30 14:36:07 WebSocket: Requesting handshake...
2012-10-30 14:36:07 WebSocket: Handshaking...
2012-10-30 14:36:07 WebSocket: Done handshaking...
2012-10-30 14:36:10 WebSocket: Resource id #14 CONNECTED!
2012-10-30 14:36:10 WebSocket: Requesting handshake...
2012-10-30 14:36:10 WebSocket: Handshaking...
2012-10-30 14:36:10 WebSocket: Done handshaking...
2012-10-30 14:36:31 WebSocket: Resource id #15 CONNECTED!
2012-10-30 14:36:31 WebSocket: Requesting handshake...
2012-10-30 14:36:31 WebSocket: Handshaking...
2012-10-30 14:36:31 WebSocket: Done handshaking...
2012-10-30 14:36:31 WebSocket: Resource id #15 disconnected!

P/S:我认为还有另一种无需手动编辑 php.ini 的方法。单击 WAMP 图标 PHP -> PHP Extensions -> PHP Socket 并勾选它。我想它也会起作用。

于 2012-10-30T14:47:00.953 回答
1

您唯一需要的是一个外壳/终端/命令行(无论您选择的操作系统如何称呼它),您可以在其中键入:

php -q /path/to/your/script.php

phpPHP 可执行文件的路径在哪里,后面是选项-q,然后是脚本的路径。这实际上并不太依赖 (X/W/M)AMP。

于 2012-01-02T13:09:37.137 回答