speeding up socket connections

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yawnmoth

    speeding up socket connections

    i'm trying to write a php script that sends an http request to a
    server, get some info. from that server, and print it to the screen.
    unfortunately, this script takes longer to connect than i'd like.
    replacing the server's ip address with 127.0.0.1 noticeably speeds
    things up, but doesn't work if someone's on a virtual host (the paths
    would be different).

    here's the script i'm using:

    <?
    $fsock = fsockopen('tcp://ipaddress',80,$ errno,$errstr,1 );
    fputs($fsock,"G ET /filename.txt HTTP/1.0\r\n");
    fputs($fsock,"H ost: domain.com\r\n\ r\n");
    while (!feof($fsock))
    echo fgets($fsock);
    fclose($fsock);
    ?>

    i'm aware that fopen would work in this particular case, but in the
    context of what i'm trying to do, it doesn't (i don't, ultimately, want
    to get the contents - i just want to send an http request and be done
    with it, for the purposes of initiating time consuming tasks such as
    backups in safe mode, without requiring the user wait for the task to
    complete).

    any ideas as to how i could speed the above code up?

    alternatively, any ideas how, when ipaddress is replaced with
    127.0.0.1, the path on the domain that's being requested could be
    adjusted to the real host (as opposed to the virtual one)?

  • Chung Leong

    #2
    Re: speeding up socket connections

    "yawnmoth" <terra1024@yaho o.com> wrote in message
    news:1109969087 .243384.101810@ l41g2000cwc.goo glegroups.com.. .[color=blue]
    > i'm aware that fopen would work in this particular case, but in the
    > context of what i'm trying to do, it doesn't (i don't, ultimately, want
    > to get the contents - i just want to send an http request and be done
    > with it, for the purposes of initiating time consuming tasks such as
    > backups in safe mode, without requiring the user wait for the task to
    > complete).[/color]

    Just because your fopen() a URL doesn't mean you have to get the contents.
    Hint: don't call fread().


    Comment

    Working...