Migrated to a Webhost, PHP Socket troubleshooting difficult

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
heinzel
Forum Newbie
Posts: 9
Joined: Mon Apr 09, 2007 7:40 am

Migrated to a Webhost, PHP Socket troubleshooting difficult

Post by heinzel »

Dear all,

I am somewhat of a PHP novice, but since I've had many years of programming experience in other languages I managed to get a rather large project up and running. On my own Apache server on my laptop. Since it is a multiplayer web application (non-commercial), I purchased webhosting and started to migrate the files there. Now I need help debugging the socket functions which do not seem to work. If any of you can give me a hint it would be greatly appreciated. Here's the background:

- I have a PHP shell script that listens for incoming sockets.
- In migrating this script to the webhost, I changed the line

Code: Select all

$address = 'localhost';
to

Code: Select all

$address = 'www.risk-online.net';
. This is later used in socket_bind.
- I am using a virtual private server with a shared IP.
- The hosting company tells me that the port I'm using is not firewalled.
- The shell script seems to run fine without timing out.
- The Flash client has been migrated fine (or so it appears), non-socket communication with the server works.
- When I try to create a socket connection from the client, it doesn't work.

Do any of you have an idea what could be wrong? Is the code I changed OK? Do I need to change more? Do I have to make sure my hosting company supports the socket process in any particular way? I am puzzled. The whole code takes up page after page and I probably shouldn't post that much here. However, if anyone is particularly interested in all the Actionscript and php functions involved, I can supply those of course.

Your help is greatly appreciated!
Thanks & best regards
Matthias
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Does your new host have the "sockets" PECL library loaded? If so in phpinfo() you'll see a "sockets" section with "Sockets Support: enabled" underneath.

Check your old host's php_info() against your new host's php_info() and look for things that are suspiciously missing.
DrTom
Forum Commoner
Posts: 60
Joined: Wed Aug 02, 2006 8:40 am
Location: Las Vegas

Post by DrTom »

It's more than likely permission problems. create_socket generally requires write permissions very few people have.

On some servers you can get around this with posix_seteuid(), but most shared servers will have this disabled but it's osmething you can try.
heinzel
Forum Newbie
Posts: 9
Joined: Mon Apr 09, 2007 7:40 am

Post by heinzel »

Hi guys, thank you for your suggestions.

I have checked the phpinfo() of the webhost, and sure enough sockets are enabled. The hosting company also claims that yes I can run a shell script and yes I can use sockets for my program. I don't know if this is also an answer to DrTom's suggestion, but I think it is.

Can anyone think of any other cause for error? I am still puzzled.
heinzel
Forum Newbie
Posts: 9
Joined: Mon Apr 09, 2007 7:40 am

Post by heinzel »

Anyone? Please help me out guys :-)

Does anyone know for sure if sockets are technically possible on a virtual private server with a shared IP? Or does it need a dedicated IP? My Hosting company gives me conflicting info on that one (Interestingly enough, the answer was yes before I digned up and no afterwards...).
Post Reply