Socket-about PHP+RRD drawing problems

Source: Internet
Author: User
Tags rrd
Recently in an application, I use the socket to collect the number of servers online and then update the RRD database, but finally did not show that the predecessor has relevant experience please advise, the boss has been urging AH;
The code is as follows:

      $ss = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);    socket_set_option($ss,SOL_SOCKET,SO_RCVTIMEO,array("sec"=>3, "usec"=>0 ) );    socket_set_option($ss,SOL_SOCKET,SO_SNDTIMEO,array("sec"=>3, "usec"=>0 ) );//$latencyStart = microtime(true); //延迟开始计时。    if(socket_connect($ss,gethostbyname($tietu_host),$tietu_port))//更新且连接成功    {        socket_write($ss,"\xfe\x01");        $data=explode("\x00",mb_convert_encoding(substr(socket_read($ss,1024),9), 'auto', 'UCS-2'));        $tietu_players=$data[3];        if(rrd_update($dbname,"N:$tietu_players")==true){            echo"数据更新成功,数据为".$tietu_players;        }else{            echo"数据更新失败";        }    }

Reply content:

Recently in an application, I use the socket to collect the number of servers online and then update the RRD database, but finally did not show that the predecessor has relevant experience please advise, the boss has been urging AH;
The code is as follows:

      $ss = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);    socket_set_option($ss,SOL_SOCKET,SO_RCVTIMEO,array("sec"=>3, "usec"=>0 ) );    socket_set_option($ss,SOL_SOCKET,SO_SNDTIMEO,array("sec"=>3, "usec"=>0 ) );//$latencyStart = microtime(true); //延迟开始计时。    if(socket_connect($ss,gethostbyname($tietu_host),$tietu_port))//更新且连接成功    {        socket_write($ss,"\xfe\x01");        $data=explode("\x00",mb_convert_encoding(substr(socket_read($ss,1024),9), 'auto', 'UCS-2'));        $tietu_players=$data[3];        if(rrd_update($dbname,"N:$tietu_players")==true){            echo"数据更新成功,数据为".$tietu_players;        }else{            echo"数据更新失败";        }    }
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.