Page 1 of 1
Call fputs from inside function, fsockopen outside?
Posted: Fri Jan 30, 2004 6:34 am
by EndTwist
Hello again,
How can I call fputs from inside a function, when I have opened the connection outside it?
Posted: Fri Jan 30, 2004 6:47 am
by AVATAr
Code: Select all
<?php
function myfunction($fpcon){
fputs($fpcon,"GET / HTTP/1.0\n\n");
}
$fp = fsockopen("www.php.net", 80, $errno, $errstr, 30);
myfunction($fp);
?>
Posted: Fri Jan 30, 2004 6:50 am
by EndTwist
Thats what I thought, but I get a "30 second timeout" when I try that.
Posted: Fri Jan 30, 2004 6:51 am
by AVATAr
it works using it outside the function
Posted: Fri Jan 30, 2004 10:17 am
by BDKR
EndTwist wrote:
Thats what I thought, but I get a "30 second timeout" when I try that.
Did you try using a '&'. In other words, passing the socket resource in by reference.
Code: Select all
/* Notice that the resource is passed in by reference */
function myfunction(&$fpcon)
{ fputs($fpcon,"GET / HTTP/1.0\n\n"); }
$fp = fsockopen("www.php.net", 80, $errno, $errstr, 30);
myfunction($fp);
See if that works.
Cheers,
BDKR
Posted: Fri Jan 30, 2004 1:34 pm
by EndTwist
unfortunately, it didn't help
Code: Select all
sendProc(1, chr(0) . chr(0) . chr(0) . chr(1) . chr(0) . chr($snFiller) . chr(strlen($screenName)) . $screenName, $socks);
sendProc(2, "toc_signon login.oscar.aol.com " . randomdigit(1) . "234 " . $screenName . " " . $encPassword . " english " . chr(34) . "AOLInstantMessenger" . chr(34) . chr(0), $socks);
function sendProc($frameType, $strWTS, &$socks) {
if (strlen($strWTS) > 2048) { exit; }
$lngSeqHi = Hi(1);
$lngSeqLo = Lo(1);
$lngLen = strlen($strWTS);
$lngLenHi = Hi($lngLen);
$lngLenLo = Lo($lngLen);
$strOut = "*" . chr($frameType) . chr($lngSeqLo) . chr($lngSeqHi) . chr($lngSeqLo) . chr($lngSeqHi) . $strWTS;
fputs($socks, $strOut);
}
Posted: Fri Jan 30, 2004 1:49 pm
by AVATAr
just a question... did you try to use it without the function?
maybe the function stuff is working..