php socket question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

i want to be able to send a packet to a http server and receive the
response, but i'm not quite sure how to do it. i thought of using
sockets, and although i have worked out how to send data to the http
server, i have no idea how to receive the responses.

any help wuld be greatly appreciated.

this is what i've got so far. i know that the server is receiving the
data because i have employed this technique before, only previously i
did not need to receive the response.


function login()
    $data  = "POST /admin/default.asp HTTP/1.1\r\n";
    $data .= etc etc etc

    $socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
    $connection = socket_connect($socket,'(*IP ADDRESS*)','80');



Re: php socket question

Take a look at the php manual item about fsockopen() at .
There are examples too.

Re: php socket question

Sticks wrote:

Quoted text here. Click to load it

Avoid using HTTP 1.1 - in my experience, PHP4 doesn't handle the chunked
transfer encoding very well. I don't know if they have sorted this out in
later versions though. The examples you are looking for are here:

Site Timeline