Hello again,
How can I call fputs from inside a function, when I have opened the connection outside it?
Call fputs from inside function, fsockopen outside?
Moderator: General Moderators
- AVATAr
- Forum Regular
- Posts: 524
- Joined: Tue Jul 16, 2002 4:19 pm
- Location: Uruguay -- Montevideo
- Contact:
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);
?>Did you try using a '&'. In other words, passing the socket resource in by reference.EndTwist wrote: Thats what I thought, but I get a "30 second timeout" when I try that.
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);Cheers,
BDKR
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);
}