We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


fsockopen, fwrite problem

Fatlog asked
Medium Priority
Last Modified: 2012-06-27

this isnt really an fsockopen or fwrite problem as such! i'm using the following code...

function http_spawn($page)
       $basepath=ereg_replace('[^/]*$', '', $_SERVER['PHP_SELF']);
       $cbSock=fsockopen('localhost', $_SERVER['SERVER_PORT'], $errno, $errstr, 5);
       if ($cbSock)
           fwrite($cbSock, "GET {$basepath}{$page} HTTP/1.1\r\n"
               ."Host: {$_SERVER['HTTP_HOST']}\r\n\r\n");

         while (!feof($cbSock))
            echo fgets($cbSock, 128);



to kick off a call to a page. got the code from...


anyway, this works fine on one server i tried it on. a redhat linux server(apache 2 i think). works perfectly. then i tried the same code on a different server and i'm getting 404 errors...

HTTP/1.1 404 Not Found Date: Fri, 24 Mar 2006 12:12:15 GMT Server: Apache/1.3.34 (Unix) PHP/4.4.2 mod_ssl/2.8.25 OpenSSL/0.9.7d FrontPage/ mod_throttle/3.1.2 Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 11c
Not Found
The requested URL /page.php was not found on this server.


Apache/1.3.34 Server at Port 80

i've tried changing paths, specifying the path to the file, the url to the file. all sorts of things. am at my wits end with this! anyone see any obviuos errors or anything at all???

Watch Question

Solutions Architect
Try taking off the very last "\r\n" in the fwrite string.


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.