fsockopen / fwrite / fgets problems...

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

    fsockopen / fwrite / fgets problems...

    i'm having some php problems.

    i have the following code on my main page:

    ------------
    $fp = fsockopen("127. 0.0.1", 49152, $errno, $errrstr, 30);
    if (!$fp)
    {
    echo "socket error: $errstr ($errno)<br />\n";
    die;
    }

    $s_mode = GetParam ($fp, ANALOG_MODE);
    ------------

    i have the following function:

    ------------
    function GetParam ($fp, $param)
    {

    if (!$fp)
    {
    echo "get parameter error: $errstr ($errno)<br />\n";
    return;
    }

    $cmd = '@B3,' . $param . '<nl>';

    fwrite ($fp, $cmd);

    $result = fgets ($fp, 128);

    //echo 'Result: '.$result; die;
    //echo "got $result in funciton\n";
    list($cut, $keep) = explode('', $result);
    list($keep, $cut) = explode('<nl', $keep);
    //echo 'res'.$result.' res';
    return $result;
    }
    ------------

    this function appears to be blowing a gasket somewhere around fwrite or
    fgets. when i try to print $result, i get the error:

    Result: @ERR:args_too_l ong

    does anyone have any know what the problem is or how to troubleshoot
    this?

    tia...

  • Jerry Stuckle

    #2
    Re: fsockopen / fwrite / fgets problems...

    Skeets wrote:[color=blue]
    > i'm having some php problems.
    >
    > i have the following code on my main page:
    >
    > ------------
    > $fp = fsockopen("127. 0.0.1", 49152, $errno, $errrstr, 30);
    > if (!$fp)
    > {
    > echo "socket error: $errstr ($errno)<br />\n";
    > die;
    > }
    >
    > $s_mode = GetParam ($fp, ANALOG_MODE);
    > ------------
    >
    > i have the following function:
    >
    > ------------
    > function GetParam ($fp, $param)
    > {
    >
    > if (!$fp)
    > {
    > echo "get parameter error: $errstr ($errno)<br />\n";
    > return;
    > }
    >
    > $cmd = '@B3,' . $param . '<nl>';
    >
    > fwrite ($fp, $cmd);
    >
    > $result = fgets ($fp, 128);
    >
    > //echo 'Result: '.$result; die;
    > //echo "got $result in funciton\n";
    > list($cut, $keep) = explode('', $result);
    > list($keep, $cut) = explode('<nl', $keep);
    > //echo 'res'.$result.' res';
    > return $result;
    > }
    > ------------
    >
    > this function appears to be blowing a gasket somewhere around fwrite or
    > fgets. when i try to print $result, i get the error:
    >
    > Result: @ERR:args_too_l ong
    >
    > does anyone have any know what the problem is or how to troubleshoot
    > this?
    >
    > tia...
    >[/color]

    Looks like whatever you're trying to write to is returning an error message.
    What's listening on socket 49152?

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    Working...