Jump to content
tdxev

[help] php soket

Recommended Posts

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

Link to comment
Share on other sites

cand citesti cu fgets e blocking pana citeste ceva... nu tot :) si returneaza ce a citit... nu asteapta tot pachetul

php.net:

Return Values

Returns 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

Link to comment
Share on other sites

nu stiu daca la asta te referi.. dar am icercat si tot acelasi rezultat il aveam


while (!feof($handle)) {
echo fgets ($handle, 1);
}

acum folosesc alta functie

fread()

vad ca returneaza tot textul.

socket_set_blocking()

acelasi rezultat(adica nu merge)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...