Is there any way to get the socket functions working in windows? (A Win32 binary compiled with them enabled, a DLL, etc)

    Ummm they always worked for me with both the default build and the Apache Module for Windows, what kind of problems are you having? Error messages? Maybe you\'re code has a typo?

      Fatal error: Call to undefined function: socket() in C:\HTTPD\HTDOCS\newEMSweb\sockettest.php on line 10

      I'm just assuming that that function should work...

      the code I'm trying, because I'm new to socket programming, is an identical copy of the first sample of code under sockets in the PHP Manual - I assume that code should work!!

      I'm using the newest PHP4 under Win32 in CGI mode.

      Please help! Thanks.

        Hey,

        Don't know if this will help you or not, but try grabbing PHP 4.0.1pl2. I tried to use the newest version and I couldn't get any of the modules in the distribution to work properly. I found that they caused any php files to take 30 seconds or more to load.

        Cheers,

        Geoff A. Virgo

          That would be because there is no function named socket() try fsockopen() instead.

          I can't seem to find the sample code of which you speak, which documentation manual are you using, in all versions I have the socket functions are under the heading Network Functions.

            http://www.php.net/manual/ref.sockets.php

            Right there on that page... the sample code I spoke of, plus if you hit <next>, on the lefthand side on of the function choices to explore in more detail is "socket()"

            is fsockopen() identical to the described socket()?

            This is strange...

              Hmmm hey thats a new chapter, I wonder if thats a new set of functions to be released in the next version of php? Looks to me like they're adding in raw socket support.

              The fsockopen() function is pretty basic, it functions just like a telnet connection sending and recieving data. It is good for things like browsing & downloading files from HTTP and FTP servers as well as many other types. I used it to create several usful functions for uses such as checking if a file exists on a remote server, downloading a complete listing of files from a remote server, streaming files through my localsystem from a remote system (this is kinda slow but it's still has it's uses for keeping files secure.)

              Basicly the fsockopen() function opens a file handle that you can read and write from, only the data isn't writen/read from disk it is read from a TCP/IP connection.

              The raw sockets on the other hand are probably going to primarily be used so that us programming types will have access to protocalls other than just TCP/IP like UDP, etc. These are good for things like pinging other system (ICMP) or getting the current time from another system running a time server.

              None of these socket() functions currently work on my copy of PHP4Win or in the downloadable copy of the PHP4 documentation, and that leads me to guess that they are not even in this build yet, maybe 4.0.3? It's funny thou, usualy the docmentation tells you this kinda need to know information.

                a year later

                Hey Birdy you are right you need the socket module it is socket.dll for win32. Then you need to modify the php.ini to show location of socket.dll.

                Shaun,
                Socket has been a part of php since as far back as I can remember php 3.8 something. fsocket is a dumbed down version kinda like socket lite.

                However to enable sockets php has to be compiled with -sockets option which for some reason nobody who releases binaries ever does. Or you need to add the dynamic module (i.e .dll).

                You can see which "optional" sockets your version of php uses by the command line
                php.exe -m

                I stopped writing on win32 because you can never seem to find the module you need for php, apache, perl etc..

                It is just to hard to get php to compile on win32.

                Your best best is to see if any win32 users did their own compile. If they did ask them if they would recompile with the -socket flag and then post it to the web.

                Hope this helps.

                  Write a Reply...