tdxev Posted May 23, 2010 Report Share Posted May 23, 2010 M-am apucat sa fac un script in php care se conecteaza la un hub insa scriptul se blocheaza in momentul in care incerc sa citesc mesajul de intampinare! Mesajul de intampinare este ceva de genul : $Lock EXTENDEDPROTOCOL_verlihub Pk=version0.9.8e-r2| VerliHub-0.9.8e-r2 ( special edition by ssNet.ro )| RunTime: 2weeks 20hours / online users: 419| System Status: Normal Mode| php code: $host = "94.176.96.7"; $port = 411; $fp = fsockopen ($host, $port, $errno, $errstr,30); if (!$fp){$result = "Error: could not open socket connection"; } else { echo fgets($fp,1024); fclose ($fp); } in momentul in care citesc doar 20 de caractere scriptul merge dar returneaza doar o parte din mesaj Quote Link to comment Share on other sites More sharing options...
Xander Posted May 23, 2010 Report Share Posted May 23, 2010 mai invata sockets e normal sa returneze asa Quote Link to comment Share on other sites More sharing options...
tdxev Posted May 23, 2010 Author Report Share Posted May 23, 2010 pai ma chinui de o ora si nu gasesc nici o rezolvare macar da-mi un indiciu daca nu vrei sa-mi spui raspunsul Quote Link to comment Share on other sites More sharing options...
Xander Posted May 23, 2010 Report Share Posted May 23, 2010 cand citesti cu fgets e blocking pana citeste ceva... nu tot si returneaza ce a citit... nu asteapta tot pachetulphp.net:Return ValuesReturns a string of up to length - 1 bytes read from the file pointed to by handle.If an error occurs, returns FALSE.Trebuie sa citesti intr-un loop pana ai tot pachetul Quote Link to comment Share on other sites More sharing options...
Ethereal Posted May 23, 2010 Report Share Posted May 23, 2010 (edited) Fgets blocheaza pana citeste 1024 bytes.Incearca asta: socket_set_blocking($fp,false); LE: sau gresesc lamentabil si xander are dreptate . Edited May 23, 2010 by Ethereal Quote Link to comment Share on other sites More sharing options...
tdxev Posted May 23, 2010 Author Report Share Posted May 23, 2010 nu stiu daca la asta te referi.. dar am icercat si tot acelasi rezultat il aveamwhile (!feof($handle)) {echo fgets ($handle, 1);}acum folosesc alta functie fread() vad ca returneaza tot textul.socket_set_blocking() acelasi rezultat(adica nu merge) Quote Link to comment Share on other sites More sharing options...
Fitty Posted May 23, 2010 Report Share Posted May 23, 2010 Merge si cu fread si cu fgets, eu o folosesc pe prima pentru ca sunt semizeu. Quote Link to comment Share on other sites More sharing options...