Sami Al-Subhi
Sami Al-Subhi

Reputation: 4672

how can I run a websocket server. I'm using WampServer 2.1

it says it clearly in the heading. I want a way to run a websocket server in apache server that comes with Wamp 2.1

update

check this page http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/ look at step 9 where it describes how to run a websocket server. that's for XAMPP. I want to do it in WAMP. Sorry if it was unclear.


udate 2

cmd on win 7

I tried to run it as in the photo but ,as you see, I'm doing that wrong. sorry guys I'm not good at command lines. could you please show me the exact way to run the websocket-server


update 3

cmd accessing php.exe

another trial and nothing happened.

Upvotes: 0

Views: 14245

Answers (2)

G.C. Looi
G.C. Looi

Reputation: 80

I have found some idea to make WAMP work with the tutorial. You need to edit the C:\wamp\bin\php\php5.3.9\php.ini and add a line extension=php_sockets.dll and then call php -q C:\wamp\www\websocket\server\startDaemon.php in cmd and the websocket will work.

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: I think there is another way without edit php.ini manually. Click on WAMP Icon PHP -> PHP Extensions -> PHP Socket and Tick it. I guess it will work too.

Upvotes: 4

deceze
deceze

Reputation: 522461

The only thing you need is a shell/terminal/command line (whatever your operating system of choice calls it) in which you type:

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

Where php is the path to the PHP executable followed by the option -q followed by the path to your script. This doesn't really depend on (X/W/M)AMP much.

Upvotes: 1

Related Questions