Hello all!

I'm having problems getting the below working.  I'm actually trying to
get a telnet socket connection working but I figured that getting it
to talk a web server would suite the same purpose to begin with.

Any ideas why it stops right after the comment "Getting welcome banner
stuff"?

Thanks,
John Cole


<?php
$message = "get / http 1.0 / \r\n";
        // where is the socket server?
        $host="10.54.1.50";
        $port = 80;
echo "starting!";
        // open a client connection
        $fp = fsockopen ($host, $port, $errno, $errstr);
echo "\r\n connected! \r\n";
echo $fp;
echo "\r\n test \r\n";
echo "--------" . $message . "--------\r\n";
        if (!$fp)
        {
                $result = "Error: could not open socket connection";
        }
        else
        {
                // get the welcome message
                echo "\r\n getting welcome banner stuff\r\n";
                fgets ($fp, 25);
                echo "got welcome message\r\n";
                // write the user string to the socket
                // echo "writing message:   " . $message;
                fputs ($fp, $message);
                echo "\r\n put the message";
                // get the result
                echo "getting result";
                $result .= fgets ($fp, 1024);
                // close the connection
//              fputs ($fp, "END");
                fclose ($fp);

                // trim the result and remove the starting ?
                $result = trim($result);
                $result = substr($result, 2);

                // now print it to the browser
        }

echo " ";
echo "\r\n\r\n";
echo $result;
?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to