View Full Version : php 5 sockets
bambii7
August 29th, 2008, 12:06 AM
Hey all,
followed a few tutorials on this site which have helped me out big time! ;)
Got real excited about the tut on sockets servers with flash for multiplayer games!
I'm stuck with the cmd.exe, I'm unfamilar with root file paths on my local server. Any help would be grand. WAMP is instaled inside 'My Documents' the .bat file is currently like
C:/Documents and Settings/Administrator/My Documents/My Wamp/php/php.exe -q C:/Documents and Settings/Administrator/My Documents/My Wamp/www/flashMultiChat/socketShell.php
But the batch file wont run. Any help or sugestions would be grand.
PS this wysiwyg is quite weird, you cant select and delete blocks of text. Have to backspace.
eirche
August 29th, 2008, 09:28 AM
use quotes
"C:/Documents and Settings/Administrator/My Documents/My Wamp/php/php.exe" -q "C:/Documents and Settings/Administrator/My Documents/My Wamp/www/flashMultiChat/socketShell.php"
bambii7
August 29th, 2008, 10:43 PM
You're a legend eirche :)
bambii7
August 30th, 2008, 02:19 AM
Hey whats the deal when running batch files through the command promt and php extenshions?
When opening the socketShell.php file through a browser the whole thing works a beaut. Flash connects fine to the local host and the messages get broadcasted across all open instances of the chat swf. Running socketShell.php through cmd.exe results in 'call to undefined function create_socket()'. The sockets are enabled.
eirche
August 30th, 2008, 06:30 AM
run phpinfo() to check if socket extension is enabled. run this directly in command prompt, not in http server.
bambii7
August 30th, 2008, 07:29 AM
Good point, I'm unfamiliar with using cmd.exe.
I can't find anything in the phpinfo() that say sockets disabled. The only thing I can find on sockets is
default_socket_timeout => 60 => 60.
So um, its a bit beyond me, how do I enable php modules here? The ini file has is enabled?
eirche
August 30th, 2008, 06:55 PM
use enable socket, uncomment the line "extension=php_sockets.dll" in php.ini
bambii7
August 31st, 2008, 12:02 AM
php.ini has had sockets enabled, after much frustration and reading I realize how clever I am! My path to php binary inside socketShell.php was the same as the tutorials \usr\bin\php. I got real excited after realizing I'd failed to change this, thought it was my answer. But me and all my smarts can't get this file path correct.
#!C:\Documents and Settings\Administrator\My Documents\My Wamp\php\php -q
does that look remotely correct?
ps.
I can't find any info on socket support enabled when running phpinfo() in cmd.exe.
eirche
August 31st, 2008, 05:45 PM
you lost me there. if socket extension is enabled then the problem is somewhere else. it's not about sockets anymore.
ask yourself, do you know how to get a simple script to run in command prompt? such as
<?php
echo "hello world";
?>
can you get this working?
bambii7
August 31st, 2008, 08:22 PM
We'll I am very new to running any thing apart from a ping in command promt. From what I've learned over the last few days, I made a file called ello.php then a bat file to a path to php.exe and the ello.php. I get hello world in the command promt by doing this.
I've googled quite a few key words and read a few forum posts and it appears others have had trouble with this. Unfortunately I cant find a solution. On this page http://www.onlamp.com/pub/a/php/2001/03/29/socket_intro.html?page=2 he says "Also make sure that the first line of the script points at your PHP binary. Then, start the server". In the tutorial the path was #!\usr\bin\php -q my local would be #!C:\Documents and Settings\Administrator\My Documents\My Wamp\Apache2\bin\php -q if I'm not mistaken.
bambii7
August 31st, 2008, 08:35 PM
And below that line Daniel Solin also says "(If you get an error saying that the socket() function is undefined, you need to get into your PHP source directory, run ./configure --enable-sockets, and then recompile and reinstall the PHP binary by running make && make install.)"
Because I've always been a wamp user I've never done too much configuring past the ini file. I've been googlen' recompile/reinstall PHP binary but those words aren't making a lot of sense to me nor can I find documentation.
My normal phpinfo() viewed in a browser returns 'socket support enabled'. Can't find any details of this when phpinfo() is run in command prompt.
eirche
August 31st, 2008, 10:25 PM
forget about the #! or recompiling or sockets.
you installed WAMP and a flash game that uses sockets. the first source for support should be from the game maker. read its documentation.
this game should consist two part, a server and a client. it looks like you are trying to start the server.
bambii7
September 1st, 2008, 01:02 AM
I haven't explained myself too well. Thanks for your help so far. The story goes I followed a tutorial/brief introduction on kirupa.com here http://www.kirupa.com/developer/flash8/php5sockets_flash8.htm on using sockets with php and flash mx. I installed wamp a few years ago. I've built a flash game in as2. But love the idea of a multi player server; and I like the idea of not spending money on smart fox server or the electro tank server. Not because they're poor quality but because I want to know about socket servers. It's always more flexible if you've written the code your self (as long as you write it proficiently).
The tutorial from kirupa (obiAdmin (raymond)) is really useful. And I know from opening the php page in a web browser it works. But for obvious development integration reasons I want it running locally. I think I'll end up needing a book on network programming and maybe Java or C++. I'm still going to look for a solution with php; Mainly because people like Daniel Solin from onlamp.com claim php will handle 95% of required functionality. And so far my googln has reaped any rewards.
eirche
September 1st, 2008, 01:12 PM
to make your life easier, add php directory to your system path. may require restart for it to take effect.
info.php
<?php
phpinfo();
?>
run this in command prompt, "php info.php > info.txt"
see if socket extension is listed in info.txt
bambii7
September 3rd, 2008, 11:22 AM
Sorry for delayed reply. I've been tied up with normal work.... booo. I'll get back to you later in the week.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.