Jump to content

[SOLVED] Sockets Enabled but not in Command Prompt


obigraphics

Recommended Posts

Hi everyone,

 

I have a slight problem that I can't seem to figure out on my Vista machine running Apache 2.2 and PHP 5.2.3. I have sockets enabled, and all runs fine when I test it in the browsers (any of them). Main focus would just be socket_create for now. Now when I test this by command prompt (and of course using correct heading info #!/usr/bin/php -q), it gives a "Call to undefined function socket_create".

 

So I looked further into this, just to make sure sockets were enabled, I used phpinfo() and sure enough its there. But when I run the same script by command prompt, everything is there except sockets. It just does not show up.

 

Here is the test script I am using.

if (($master = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {

echo "socket_create() failed, reason: " . socket_strerror($master) . "\n";

}else{
echo " socket_create() worked!!";
}

 

As I said above, it works fine with a browser, but does not work by command prompt.

 

Hope I can get some help thanks a lot!

Two issues could be relevant here.. Often the command line and web PHP use different executables.  Also, they often use different copies of php.ini

 

So either one of those could cause the problem.

 

I can't give you any more detailed help as I'm not too familiar with php on windows.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.