Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi all. I have a problem with sockets. I wrote a script that connects to a dc hub. I want to close the connection when the socket stops reciving data from the server. I tryed to do this with socket_select but it doesn't work. I have this:Code: Select all
$fp = fsockopen($hub_address, $hub_port, $errno, $errstr, $timeout);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
}else{
echo "[+] Socket created<br>\n";
echo "[+] Connected<br>\n";
//ob_flush();
//stream_set_blocking($fp, FALSE );
//stream_set_timeout($fp, $timeout);
//$status = socket_get_status($fp);
$blank = 0;
while(!feof($fp))
{
$out = fread($fp,4096);
$r = array($out);
if ($num_changed_stream = stream_select($r, $write = NULL, $except = NULL, 1) > 1)
{
echo 'reciving data from server';
}
.....If anyone knows how to resolve this problem or he has another solution please post it here.
Regards!
Weirdan | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]