The PHP Socket Server
Step-by-Step on Windows

Return to Index

If you're reading this, then FlashChat is installed on your web server, but without the socket server option enabled. If it's not installed, stop reading this and install it.

Now, let's take this step by step.

Step 1: Enable sockets in PHP

Using a good text editor like TextPad, open your PHP.ini file. This is probably located in your C:\Windows folder. Locate this line:


Remove the semicolon before this line, so that it now reads:


Then, restart your server. To verify that the socket server is running correctly, create a new php file with the following contents:

<?php phpinfo(); ?>

Then, put this file your FlashChat folder, and open it with a web browser. You should see a blue page listing your PHP settings. If the socket server is running as it should, you will find this section:

If you don't see this, then STOP and contact your web host, or at least someone who is highly proficient in PHP/MySQL setup. The socket server will not work until this option is correctly enabled.

Step 2: Set FlashChat's /inc/config.php

Now, open FlashChat's config.php file, which is located in the "inc" folder, with a good text editor. Locate this line, and change it from "false" to "true". When editing any PHP files in FlashChat, be careful of syntax errors, and do not add any extra spaces or carriage returns after trailing "?>" symbols.

'enableSocketServer' => true,

Step 3: Set host configuration

Open the "config.socketSrv.php" file, located in the /inc/patServer folder of FlashChat. Set the "host" property to the domain of your server, like "" or the IP address of your server. I tested this locally, so I used, although "localhost" would also have worked. Leave all other settings as they are.

If you are using a firewall, you may need to open the port that the socket server is listening on. By default, this is port 9090.

Step 4: Copy cli/php.exe as the new php.exe

In your PHP folder (located at C:\AppServ\php on my system, but this is likely to be different for you), I have a folder called "cli". Within this folder, there is another version of php.exe. Copy the php.exe from the "cli" folder to your PHP root folder. But first, rename your existing php.exe to php.exe.bak so that you can restore it if needed.

Now, restart your web server again to ensure that PHP is still working properly.

Step 5: Configure runServer.bat

Using a good text editor, open /inc/patServer/runServer.bat, and set the following paths: your path to php.exe, and the path to runServer.php. These are the "full system" paths. After editing, my file looked like this (note: the "pause" command is still present on the second line):

"C:\AppServ\php\php.exe" "C:\AppServ\www\chat\inc\patServer\runServer.php"

Now, start "runServer.bat" by simply double-clicking it. On my system I have two firewalls: a hardware firewall and a software firewall. You may need to adjust your firewall settings temporarily to accomodate for your changes.

Step 6: Start Chatting!

Ok, we should be done at this point. Let's test it out by re-starting FlashChat. If you currently have a FlashChat window open, close it and re-login. Leave the runServer.bat window open, though!

If the socket server is working correctly, you should observe that your messages appear much quicker, and the load on your server should be substantially reduced.

Auto-starting and Debugging

If you receive a "Socket server connection failed" error, then check your socketServer.log file for possible error messages. This file is located in the /inc/patServer folder of FlashChat. Also, re-check the above steps to ensure that syntax errors were not introduced at any point.

Now, you probably don't want to have the runServer.bat file open all the time. This file is really just intended as a debug tool, so that you can get the basic setup working. Once you have confirmed that the socket server works, you should open "winsrvHide.exe" and specify the php.exe file path. Then click "Start Server".

This .exe file is identical to runServer.bat, except with the extra options that allow you to restart the server in the event of a crash. If this .exe is running, you should close the runServer.bat file, since you should only have a single instance of the socket server running at one time.

When you minimize this dialog window (just minimize, don't close!), a tray icon will appear with a little happy face. Clicking this icon will allow you to start or stop the server.

When you run the .exe file, the "winsrv.ini" file (in the /inc/patServer folder) will be written with the values that you specify, for example:


You don't have to manually edit this file, but you should ensure that it's writable.

More information about the socket server can be found in the Socket Server PDF file, which comes with your FlashChat download.

Thanks for using FlashChat, and good luck!