[thelist] Sockets problem...

Rob Schumann roblgs at cscoms.com
Sat Mar 8 10:07:00 CST 2003


Apologies if this arrives twice... originally sent from the wrong email
account, so probably will be blocked.

Hi,

I'm a little new to sockets and http headers and could use a few
pointers...

Here is my code fragment (excuse linewrap)

$commsSock = fsockopen ( COMMS_URI, COMMS_PORT, $commsErrno,
$commsErrstr, 45);
if ( $commsSock ) {
    $action   = "DoSomething";
    $request =  "action=$action";

    $header = "POST /scripts/special/API.cgi HTTP/1.1\r\n";
    $header .= "Host: " . COMMS_URI . "\r\n";
    $header .= "Content-length: " . strlen($request) . "\r\n\r\n";

    fputs ( $commsSock, $header . $request);
    while (!feof($commsSock)) {
        echo fgets ($commsSock, 128);
    }
   fclose ($commsSock);
}

This is what gets sent...
POST /scripts/special/API.cgi HTTP/1.1 Host: some.domain.com
Content-length: 25 action=DoSomething


And this is what comes back, which on the face of it is an access denied
error, although with an OK status attached as well.


HTTP/1.0 200 OK Date: Sat, 08 Mar 2003 16:09:16 GMT Server: Apache
X-returndesc: Access denied Proxy-x-forwarded-for: 161.58.235.59
X-returncode: 0 Content-Type: text/plain X-Cache: MISS from webserver
Connection: close 0, Access denied

SO, the question... is this me, or something at the server end? The
domain I'm using connects fine (fsockopen), so I'm a bit bemused by the
"access denied".

Thanks in advance


Rob

Rob Schumann
Managing Director                   M: +66 (0)1 860 4533
RS-Tech Consulting Co., Ltd.        T: +66 (0)2 516 2991
70/592 Moo 3 Krisdanakorn 19,       F: +66 (0)2 516 4025
Klong Nung, Klong Luang,            E:    robs at rs-tc.com
Pathum Thani 12120,                    roblgs at cscoms.com
Thailand                        W: http://www.rs-tc.com/



More information about the thelist mailing list