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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.