I'm fairly new to PHP and am trying to make a script that connects to a MUSH, logs in, sends some commands, reads some data back, and then exits.
I have the following code: ########## start code ############
$thresh = fsockopen($hostname, $port, &$errno, &$errstr, $timeout);
if(!$thresh) { echo "Connection Failed<br>\n"; echo "$errstr ($errno)<br>\n"; exit(); } else { echo "Connected<br>\n"; $last = 0; fputs($thresh, "connect USERNAME PASSWORD"); while($tmp = fgets($thresh, 1024)) { echo $tmp . "<br>"; } echo "Closing..";
} fclose($thresh); ########### end code ##########
It is connecting to the game, I can see that form inside the game.
However it is not logging in (connect USERENAME PASSWORD).
Also, I am not sure how to change the while loop, because I game never breaks contact, I believe there is always something coming in.
I had tried feof($thresh) first of all, but that gave the same result - i.e. hanging as if waiting for more input without moving on.
Does anyone have any suggestions for me. Has anyone done this sort of script before, can they show me theirs, point me to some specific help?
many thanks
-- Azrael
("\''/").___..--'''"-._ `0_ O ) `-. ( ).`-.__.`) (_Y_.)' ._ ) `._ `. ``-..-' _..`--'_..-_/ /--'_.' .' ((i).-'' ((i).' (((.-'
Of all God's creatures there is only one that cannot be made the slave of the lash. That one is the cat. If man could be crossed with a cat it would improve man, but it would deteriorate the cat.
ICQ#52944566 Registered Linux User: 269002
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php