你自己先编好一套通讯协议,就按协议用C/C++写一个服务器端,用PHP写成客户端,对系统要求不高的呀.
只是把客户端换种语言来写罢了.

解决方案 »

  1.   

    请看下面这个socket连接函数,是在我这头客户端的,控制中心告诉我这样肯定能得到返回值,但我一调试就出错,错误指针指在调用sock函数的那行:
    function sock($puts_type,$puts_value){
          global $sock_host,$sock_port,$se_adm_user,$se_adm_pass,$adm_access,$user;
            //print "$sock_host $sock_port";
          $fp=fsockopen("$sock_host","$sock_port",&$errno,&$errstr,1);
            if(!$fp){
                    print "<p align=center>网络忙!请稍后再进行连接。</font>";
                    exit;
            }else{
                    /**************************/
                    //检验权限
                    if(!$se_adm_user) $aa=$user;
                    else $aa=$se_adm_user;                if(!($puts_type=="SendMail" || $puts_type=="CheckProgress")){
                            $check=sockcheck("ManagerFunction","$aa||$puts_type");
                            //$check[0]="0000";
                            //$check[1]="1";
                            if($check[0]=="0000"){
                                    if($check[1]==0){
                                            print "<p>你没有权限($aa:$puts_type $check[0] $check[1])</p>";
                                            //return;
                                            exit;
                                    }else $adm_access="$check[1]";
                            }else{
                                    $err_msg=err($check[0]);
                                    print "$err_msg";
                                    exit;
                            }
                    }
                    /**************************/
                    //print "$adm_access sdf";
                    $puts_temp="content-type:$puts_type\r\ncontent-length:1024\r\ncontent-value:$puts_value||";
                    $len=strlen($puts_temp);
                    flush();
                    $high=dec2hex(floor($len/256));
                    $low=dec2hex($len%256);
                    $puts="\x02$high$low".$puts_temp;
                    fputs($fp,"$puts",4096);
                    $a1=fgets($fp,128);
                    $a2=fgets($fp,128);
                    $str=fgets($fp,1024);
                    $str1=fgets($fp,1024);
                    if(substr($str1,0,13)=="content-value") $str=$str1;
                    fclose($fp);
                    print "发送:$puts_value";
                    print "<br>接收: $str $str1";
                    $str=substr($str,14,strlen($str)-13);
                    $str=trim($str);
                    $row=explode("||",$str);
                    return($row);
            }