Re: PHP sockets enabled but socket_create() gives an error call to undefined function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We added the extension=sockets.so to php.ini but it didn't work. However,
the problem was there was no sockets.so extension anywhere to be found.

i searched if I could install or add sockets.so extension. Couldn't find
anything.

Still looking for it.

Thank you for all the help.

-Suyash


On Tue, Nov 2, 2010 at 5:30 PM, Nicholas Kell <nick@xxxxxxxxxxxxxxxx> wrote:

>
> On Nov 2, 2010, at 3:23 PM, Suyash R wrote:
>
> >
> > No, our dept.'s admin wants to know where is sockets.so file on disk and
> why should we try this when the phpinfo() displays sockets being enabled?
> >
> > Can help me find sockets.so file I don't know where it is It's a shared
> object right are they stored on disk as individual files or all together
> compiled into a binary........
> >
> > Thank you
> >
> > Suyash Ramineni
> > On Tue, Nov 2, 2010 at 3:55 PM, Nicholas Kell <nick@xxxxxxxxxxxxxxxx>
> wrote:
> >
> > On Nov 2, 2010, at 2:50 PM, Suyash R wrote:
> >
> > > My admin disagrees and I have questions too.
> > >
> > > The phpinfo() fuction displays that sockets have been enabled. If
> > > extension=sockets.so is an alternate way to enable sockets, then why
> should
> > > this be done twice?
> > >
> > > Suyash Ramineni
> > > On Mon, Nov 1, 2010 at 2:35 PM, Nicholas Kell <nick@xxxxxxxxxxxxxxxx>
> wrote:
> > >
> > >>
> > >> On Nov 1, 2010, at 1:12 PM, Suyash R wrote:
> > >>
> > >>> No, sockets.so in not included in any of the machines php.ini file.
> > >> However, I found that Linux machine's php.ini doesn't include
> sockets.so and
> > >> sockets work fine on it but don't work on the Solaris machine.
> > >>>
> > >>> Is it required to be included only in Solaris?
> > >>>
> > >>> On Mon, Nov 1, 2010 at 1:41 PM, Nicholas Kell <nick@xxxxxxxxxxxxxxxx
> >
> > >> wrote:
> > >>>
> > >>> On Nov 1, 2010, at 12:08 PM, crrrrrrr errrrrrr wrote:
> > >>>
> > >>>> Yes, the http ( Apache user) has rl ( read permission) on the php
> file
> > >> with
> > >>>> sockets code in it. I think write access is unnecessary for Apache
> > >> user.
> > >>>>
> > >>>> On Mon, Nov 1, 2010 at 12:50 PM, Nicholas Kell <
> nick@xxxxxxxxxxxxxxxx
> > >>> wrote:
> > >>>>
> > >>>>>
> > >>>>> On Nov 1, 2010, at 11:44 AM, crrrrrrr errrrrrr wrote:
> > >>>>>
> > >>>>>> Yes, the phpinfo() shows that sockets are enabled in both
> machines.
> > >>>>>> On Mon, Nov 1, 2010 at 12:43 PM, Bastien Koert <phpster@xxxxxxxxx
> >
> > >>>>> wrote:
> > >>>>>>
> > >>>>>>> On Mon, Nov 1, 2010 at 12:40 PM, crrrrrrr errrrrrr <
> > >> r.suyash@xxxxxxxxx>
> > >>>>>>> wrote:
> > >>>>>>>> Hello,
> > >>>>>>>>
> > >>>>>>>> I was trying to create a socket connection from a Solaris
> machine
> > >> to a
> > >>>>>>> Red
> > >>>>>>>> Hat machine  to get the PATH in Red Hat machine remotely on
> Solaris
> > >>>>>>> machine
> > >>>>>>>> and display it to the user.
> > >>>>>>>>
> > >>>>>>>> We have a PHP 5.1.6 installation on a Linux server (Apache) and
> PHP
> > >>>>>>> 5.2.6.
> > >>>>>>>> on a Unix(Solaris) server(Apache) . The PHP version on Solaris
> is
> > >>>>>>> compiled
> > >>>>>>>> with --enable sockets and phpinfo() displays that the sockets
> are
> > >>>>>>> enabled.
> > >>>>>>>> In spite of this we get the following error when using this
> piece
> > >> of
> > >>>>> code
> > >>>>>>>> from the Solaris machine.
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>>> The error:
> > >>>>>>>>
> > >>>>>>>> PHP Fatal error:  Call to undefined function socket_create() in
> > >> /XXX/
> > >>>>>>>> 5server.php<
> > >>>>>>>
> http://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php
> > >>>
> > >>>>>>>> on
> > >>>>>>>> line 21
> > >>>>>>>>
> > >>>>>>>> The code;
> > >>>>>>>>
> > >>>>>>>> <?php
> > >>>>>>>>
> > >>>>>>>> set_time_limit(0);
> > >>>>>>>>
> > >>>>>>>> //ip of the server
> > >>>>>>>> $addr = 'xxx.xxx.xxx.xxx';
> > >>>>>>>>
> > >>>>>>>> //port of the server
> > >>>>>>>> $port = 2xxx;
> > >>>>>>>>
> > >>>>>>>> //create a socket
> > >>>>>>>> $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);  /* This
> is
> > >> line
> > >>>>> no
> > >>>>>>> 21
> > >>>>>>>> in the code. i have ommitted a few header comments */
> > >>>>>>>>
> > >>>>>>>> //bind this socket with the above ip and port
> > >>>>>>>> $ret = socket_bind($sock, $addr, $port);
> > >>>>>>>>
> > >>>>>>>> do {
> > >>>>>>>> $ret = socket_listen($sock, 10);
> > >>>>>>>> $msgSock = socket_accept($sock);
> > >>>>>>>> $buf = socket_read($msgSock, 1024);
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>>> Please let me know if you need any further details I might have
> > >> missed.
> > >>>>>>>>
> > >>>>>>>> Thank you.
> > >>>>>>>>
> > >>>>>>>> Suyash Ramineni
> > >>>>>>>>
> > >>>>>>>
> > >>>>>>>
> > >>>>>>> check phpinfo() to see if the sockets have been activated in the
> ini
> > >>>>> file.
> > >>>>>>> --
> > >>>>>>>
> > >>>>>>> Bastien
> > >>>>>>>
> > >>>>>>> Cat, the other other white meat
> > >>>>>>>
> > >>>>>
> > >>>>>
> > >>>>> I think that I messed up sending my last email, I apologize.
> > >>>>>
> > >>>>> Is the user that Apache is running under configured for the proper
> > >> read
> > >>>>> write access to the socket file?
> > >>>>>
> > >>>>>
> > >>>>> --
> > >>>>> PHP General Mailing List (http://www.php.net/)
> > >>>>> To unsubscribe, visit: http://www.php.net/unsub.php
> > >>>>>
> > >>>>>
> > >>>
> > >>> Oops, included in php.ini, not the Apache config.
> > >>>
> > >>>
> > >>> --
> > >>> PHP General Mailing List (http://www.php.net/)
> > >>> To unsubscribe, visit: http://www.php.net/unsub.php
> > >>>
> > >>>
> > >>
> > >>
> > >> Since you complied with --enable-sockets, you shouldn't even need
> > >> sockets.so to be dynamically loaded. But at this point, it is
> something that
> > >> I would try anyway.
> > >>
> > >> Add:
> > >>
> > >> extension=sockets.so
> > >>
> > >> in your php.ini file just to see if it brings the function to light.
> > >>
> > >> Your Linux installs I am sure were compiled with it in it. Especially
> if it
> > >> is a dist package.
> > >>
> > >> The absence of the function is telling me that PHP is not compiled
> with
> > >> --enable-sockets. If it was compiled in properly, you would be getting
> > >> different errors. I am not saying that you didn't do it. Something may
> have
> > >> happened in the process.
> > >>
> > >> By adding the sockets.so, you are adding the extension dynamically,
> incase
> > >> you were mistaken by the compile or incase there was some sort of
> anomaly
> > >> that the rest of PHP compiled but the sockets section was botched.
> Solaris
> > >> is (I guess) known to be lacking when it comes to C compilers (at
> least
> > >> according to the Unix geeks that I sit next to at work). But it seems
> to me
> > >> that it would all have failed or it would have all worked.
> >
> > So did you try it?
> >
> >
> http://bytes.com/topic/php/answers/483538-php-undefined-functon-socket_create
> >
> >
> >
>
>
>
>
> The reasoning is: The fact that you are getting the fatal error means that
> the binary of PHP that you are running is not bringing the function
> socket_create() to light. So what this means is that for some unknown reason
> --enable-sockets isn't in effect. So, as I described earlier: adding the
> extension in the php.ini file is just dynamically loading the extension that
> we thought was compiled in. It's just a measure to ensure that the
> socket_create() function is available.
>
>
> Actually by just adding:
>
> extension=sockets.so
>
> in the php.ini file will just work. sockets.so will be on PHP's path.
>
> But as it seems, adding the line to the php.ini file seems to be an act of
> congress, so perhaps a few other function calls to the same extension may
> clear up some things. So, can you call any other functions that are loaded
> in the sockets.so extension? I can't remember any of them off the top of my
> head, but I am sure google will turn a few up. What about any other
> extension? What is the version of Solaris that you are on?
>
> When I suggested adding the line to php.ini, it seemed to me like it would
> have been a quick turnaround task. I guess I didn't realize the procedures
> involved.
>
>
>
>
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux